Documentation ¶
Index ¶
- func DownloadHandle(ctx context.Context, resp http.ResponseWriter, ds DownloadStorager, ...) (err error)
- func FromDownloadFilenameContext(ctx context.Context) (downloadFilename string, ok bool)
- func GetMultipartFileSize(file multipart.File) (size int64, err error)
- func NewDownloadBeforeContext(ctx context.Context, f DownloadBefore) context.Context
- func NewDownloadFilenameContext(ctx context.Context, downloadFilename string) context.Context
- func NewIncomingContext(ctx context.Context, md Metadata) context.Context
- func NewRenameContext(ctx context.Context, f Rename) context.Context
- type DefaultDownloadStorage
- type DefaultStorage
- func (ds *DefaultStorage) Download(ctx context.Context, dist io.Writer, filename string) (info DownloadFileInfoer, err error)
- func (ds *DefaultStorage) Exist(_ context.Context, filename string) (exist bool, err error)
- func (ds *DefaultStorage) Remove(_ context.Context, filename string) (err error)
- func (ds *DefaultStorage) Upload(ctx context.Context, read io.Reader, filename string) (fullName string, err error)
- type DefaultUploadStorage
- type DownloadBefore
- type DownloadFileInfoer
- type DownloadStorager
- type Downloader
- type Exister
- type Metadata
- type Remover
- type Rename
- type Storager
- type UploadFileInfoer
- type UploadStorager
- type Uploader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DownloadHandle ¶
func DownloadHandle(ctx context.Context, resp http.ResponseWriter, ds DownloadStorager, filename string) (err error)
DownloadHandle 下载处理
func FromDownloadFilenameContext ¶
FromDownloadFilenameContext ...
func GetMultipartFileSize ¶
GetMultipartFileSize 获取上传文件大小 相关问题:https://github.com/golang/go/issues/19501
func NewDownloadBeforeContext ¶
func NewDownloadBeforeContext(ctx context.Context, f DownloadBefore) context.Context
NewDownloadBeforeContext ...
func NewDownloadFilenameContext ¶
NewDownloadFilenameContext ...
func NewIncomingContext ¶
NewIncomingContext creates a new context with incoming md attached.
Types ¶
type DefaultDownloadStorage ¶
type DefaultDownloadStorage struct { *DefaultStorage // contains filtered or unexported fields }
DefaultDownloadStorage 默认下载
func NewDefaultDownloadStorage ¶
func NewDefaultDownloadStorage(dispositionType string) *DefaultDownloadStorage
NewDefaultDownloadStorage 创建默认存储
func (*DefaultDownloadStorage) DispositionType ¶
func (d *DefaultDownloadStorage) DispositionType() string
DispositionType Disposition Type
type DefaultStorage ¶
type DefaultStorage struct {
BasePath string
}
DefaultStorage 默认存储
func (*DefaultStorage) Download ¶
func (ds *DefaultStorage) Download(ctx context.Context, dist io.Writer, filename string) (info DownloadFileInfoer, err error)
Download 下载
type DefaultUploadStorage ¶
type DefaultUploadStorage struct {
*DefaultStorage
}
DefaultUploadStorage 默认上传
func NewDefaultUploadStorage ¶
func NewDefaultUploadStorage() *DefaultUploadStorage
NewDefaultUploadStorage 创建默认存储
func (*DefaultUploadStorage) MaxMemory ¶
func (*DefaultUploadStorage) MaxMemory() int64
MaxMemory 最大上传大小
type DownloadBefore ¶
type DownloadBefore func(info DownloadFileInfoer)
DownloadBefore 下载之前
func FromDownloadBeforeContext ¶
func FromDownloadBeforeContext(ctx context.Context) (f DownloadBefore, ok bool)
FromDownloadBeforeContext ...
type DownloadFileInfoer ¶
type DownloadFileInfoer interface { // Size 文件大小 Size() int64 // Filename 文件名 Filename() string // Metadata 获取元数据 Metadata() Metadata }
DownloadFileInfoer 下载file信息接口
type DownloadStorager ¶
type DownloadStorager interface { Downloader DispositionType() string }
DownloadStorager 下载接口
type Downloader ¶
type Downloader interface {
Download(ctx context.Context, write io.Writer, filename string) (info DownloadFileInfoer, err error)
}
Downloader 下载
type Metadata ¶
Metadata 元数据
func FromIncomingContext ¶
FromIncomingContext returns the incoming metadata in ctx if it exists.
type UploadFileInfoer ¶
type UploadFileInfoer interface { // FullName 完整的文件名 // 包含路径 FullName() string // Filename 文件名 Filename() string // Size 文件大小 Size() int64 // Header 获取MIMEHeader Header() textproto.MIMEHeader }
UploadFileInfoer 上传file信息接口
func UploadHandle ¶
func UploadHandle(ctx context.Context, r *http.Request, us UploadStorager, name string) (infos []UploadFileInfoer, err error)
UploadHandle 上传处理
type UploadStorager ¶
UploadStorager 上传接口