Documentation
¶
Index ¶
Constants ¶
View Source
const ( GIF = "image/gif" PNG = "image/png" JPEG = "image/jpeg" BMP = "image/bmp" WEBP = "image/webp" ICO = "image/vnd.microsoft.icon" )
Image types according to the MIME specification.
Variables ¶
View Source
var ( // ErrDisallowedType is returned when the uploaded // file type is not allowed. ErrDisallowedType = errors.New("File type is not allowed") // ErrFileSize is returned when the uploaded file // size exceeds the max file size limit. ErrFileSize = errors.New("File size exceeds max limit") )
View Source
var ( PopularTypes = ImageTypes{GIF, PNG, JPEG} AllTypes = ImageTypes{GIF, PNG, JPEG, BMP, WEBP, ICO} )
Convenience set of image types.
Functions ¶
This section is empty.
Types ¶
type ImageTypes ¶
type ImageTypes []string
ImageTypes defines the allowed types for an uploaded image.
type Options ¶
type Options struct { MaxFileSize int64 AllowedTypes ImageTypes }
Options defines the available options for an image upload.
type UploadedImage ¶
type UploadedImage struct { Type string // contains filtered or unexported fields }
UploadedImage defines an uploaded image.
func New ¶
New returns a new UploadedImage object if the uploaded file could be parsed and validated as an image, otherwise it returns an error.
The key parameter should refer to the name of the file input from the multipart form.
func (*UploadedImage) Close ¶
func (ui *UploadedImage) Close() error
Close closes an uploaded image.
Click to show internal directories.
Click to hide internal directories.