forms

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// The total upload limit allowed to upload file
	// attachments.
	UploadLimit = 5
)

Variables

View Source
var (
	// AllowedMimes represents the mime types permitted
	// to be attached to forms.
	AllowedMimes = []string{
		"text/plain",
		"image/jpeg",
		"image/png",
		"image/svg+xml",
		"application/pdf",
		"application/msword",
		"application/vnd.ms-word.document.macroenabled.12",
		"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
		"application/msword",
	}
)

Functions

func ToStruct

func ToStruct(form domain.Form) interface{}

Struct returns the dynamic struct used for validation.

Types

type Attachment

type Attachment struct {
	MIMEType string
	Filename string
	MD5name  string
	Data     []byte
	Size     int64
}

Attachment defines the mail file that has been uploaded via the forms endpoint. It contains useful information for sending files over the mail driver.

func (*Attachment) SizeMB

func (a *Attachment) SizeMB() int

SizeMB

Returns the attachment file size in megabytes.

type Attachments

type Attachments []Attachment

Attachments defines the slice of mail attachments

func (Attachments) ToMail

func (a Attachments) ToMail() mail.Attachments

type Reader

type Reader struct {
	Form        *domain.Form
	Reader      dynamicstruct.Reader
	StoragePath string
}

func NewReader

func NewReader(form *domain.Form, path string) *Reader

func (*Reader) Values

func (r *Reader) Values() (domain.FormValues, Attachments, error)

type Sender

type Sender struct {
	Attachments []Attachment
	Fields      domain.FormValues
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL