Documentation ¶
Overview ¶
Package upload implements image upload handlers.
Index ¶
Constants ¶
View Source
const ( // ErrNoSingleFile returned when does not contain single file in field 'file' ErrNoSingleFile = "field 'file' does not contains single item" // ErrIncorrectData returned when field data does not contain valid base64 encoded data ErrIncorrectData = "incorrect data format" // ErrNotImage returned when media type isn't supported by underlying image processing package ErrNotImage = "Unsupported media type" // ErrNoCTypeExt returned when filename does not contain extension and we can't get it from content type ErrNoCTypeExt = "File ext for content type not found" // ErrFmtBadDownload returned when download status != 200 ErrFmtBadDownload = "Image download failed (%d)" // Base64MinCommaIndex holds minimal base64 image prefix len Base64MinCommaIndex = 21 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { DownloadLimit int64 `long:"download_limit" default:"8" description:"External image size limit (Mb)"` Dir string `long:"dir" default:"data/img" description:"Image upload destination"` PreviewDir string `long:"preview_dir" default:"data/preview" description:"Preview image destination"` PreviewWidth int `long:"preview_width" default:"100" description:"Preview image width"` PreviewHeight int `long:"preview_heigth" default:"100" description:"Preview image heigth"` UseRandomName bool `long:"random_name" description:"Do not keep uploaded image filename"` }
Config holds all config vars
type HTTPError ¶
type HTTPError struct {
// contains filtered or unexported fields
}
HTTPError holds error with HTTP status
func NewHTTPError ¶
NewHTTPError returns new HTTPError
type Service ¶
type Service struct { Config *Config Log loggers.Contextual // contains filtered or unexported fields }
Service holds upload service
func (Service) HandleBase64 ¶
HandleBase64 stores file received as base64 encoded string
func (Service) HandleMultiPart ¶
HandleMultiPart stores image from multipart form
Click to show internal directories.
Click to hide internal directories.