Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func SetConfig ¶
func SetConfig(cfg *UploadConfig)
SetConfig set upload the configuration parameters
Types ¶
type FileInfo ¶
type FileInfo struct { // file name Name string // file size Size int64 // file the full path Path string // file extension Ext string }
FileInfo file information
func Upload ¶
func Upload(r *http.Request, key string, fnh FileNameHandle, fsh FileSizeHandle) (*FileInfo, error)
Upload upload a single file
func UploadMulti ¶
func UploadMulti(r *http.Request, key string, fnh FileNameHandle, fsh FileSizeHandle) ([]*FileInfo, error)
UploadMulti upload multiple files
func UploadReader ¶
func UploadReader(r io.Reader, fnh FileNameHandle, fsh FileSizeHandle) (*FileInfo, error)
UploadReader upload data stream file
type FileNameHandle ¶
FileNameHandle filename handling
type FileSizeHandle ¶
FileSizeHandle file size limit handing
type FileStoreConfig ¶
type FileStoreConfig struct { // rewrite the existing files Rewrite bool }
FileStoreConfig file store configuration parameters
type Storer ¶
type Storer interface { // the file data storage Store(filename string, r io.Reader, size int64) error }
Storer upload data storage interface
func NewFileStore ¶
func NewFileStore(cfgs ...*FileStoreConfig) Storer
NewFileStore create a file store
type UploadConfig ¶
type UploadConfig struct { // the base path of storing files BasePath string // file size limit(the default is not limit) SizeLimit int64 // The whole request body is parsed and up to a total of maxMemory bytes of // its file parts are stored in memory, with the remainder stored on // disk in temporary files(the default of 32M). MaxMemory int64 }
UploadConfig upload the configuration parameters
type Uploader ¶
type Uploader interface { // upload a single file Upload(r *http.Request, key string, fnh FileNameHandle, fsh FileSizeHandle) (*FileInfo, error) // upload multiple files UploadMulti(r *http.Request, key string, fnh FileNameHandle, fsh FileSizeHandle) ([]*FileInfo, error) // upload data stream file UploadReader(r io.Reader, fnh FileNameHandle, fsh FileSizeHandle) (*FileInfo, error) }
Uploader file upload interface
func NewUploader ¶
func NewUploader(store Storer, cfgs ...*UploadConfig) Uploader
NewUploader create a file uploader
Click to show internal directories.
Click to hide internal directories.