Documentation
¶
Overview ¶
Package filesystem provides high-level file upload, download, validation, image helpers, and storage driver dispatch.
Index ¶
- Constants
- func CropImage(reader io.Reader, writer io.Writer, rect CropRect, format string, quality int) error
- func HookValidateFile(ctx context.Context, fs *FileSystem, file core.FileInfo) error
- func ValidateImageInfo(info ImageInfo, limit ImageLimit) error
- type CropRect
- type FileSystem
- func (fs *FileSystem) CleanHooks(name string)
- func (fs *FileSystem) Close() error
- func (fs *FileSystem) Config() core.Config
- func (fs *FileSystem) Delete(paths ...string) error
- func (fs *FileSystem) DispatchHandler() error
- func (fs *FileSystem) Download(ctx context.Context, path string, writer io.Writer, ...) error
- func (fs *FileSystem) Get(path string) (io.ReadCloser, error)
- func (fs *FileSystem) Handler() core.Handler
- func (fs *FileSystem) InitUpload(ctx context.Context, req UploadInitRequest) (*core.UploadCredential, error)
- func (fs *FileSystem) List(path string) ([]core.Object, error)
- func (fs *FileSystem) Put(file core.FileHeader) error
- func (fs *FileSystem) Recycle()
- func (fs *FileSystem) Source(path string, ttl time.Duration) (string, error)
- func (fs *FileSystem) Token(info core.FileInfo, ttl time.Duration) (*core.UploadCredential, error)
- func (fs *FileSystem) Trigger(ctx context.Context, name string, file core.FileInfo) error
- func (fs *FileSystem) Upload(ctx context.Context, file core.FileHeader) error
- func (fs *FileSystem) UploadChunk(ctx context.Context, uploadID string, index int, reader io.Reader) (*UploadChunkResult, error)
- func (fs *FileSystem) UploadCroppedImage(ctx context.Context, reader io.Reader, info core.FileInfo, rect CropRect, ...) (core.FileInfo, error)
- func (fs *FileSystem) UploadFromURL(ctx context.Context, rawURL string, info core.FileInfo) (core.FileInfo, error)
- func (fs *FileSystem) UploadStatus(uploadID string) (*UploadStatus, error)
- func (fs *FileSystem) UploadStream(ctx context.Context, reader io.Reader, info core.FileInfo) (core.FileInfo, error)
- func (fs *FileSystem) Use(name string, hook Hook) error
- func (fs *FileSystem) ValidateExtension(name, path string) bool
- func (fs *FileSystem) ValidateFileInfo(file core.FileInfo) error
- func (fs *FileSystem) ValidateFileName(name, path string) bool
- func (fs *FileSystem) ValidateFileSize(size int64) bool
- type Hook
- type ImageInfo
- type ImageLimit
- type Option
- func WithAllowedExtensions(exts ...string) Option
- func WithChunkSize(chunkSize int64) Option
- func WithMaxSize(maxSize int64) Option
- func WithNameRules(dirRule, fileRule string) Option
- func WithTempDir(tempDir string) Option
- func WithTokenTTL(ttl time.Duration) Option
- func WithUploadDir(uploadDir string) Option
- type UploadChunkResult
- type UploadInitRequest
- type UploadSession
- type UploadStatus
Constants ¶
View Source
const ( HookBeforeUpload = "BeforeUpload" HookAfterUpload = "AfterUpload" HookAfterUploadFailed = "AfterUploadFailed" HookAfterValidateFailed = "AfterValidateFailed" )
View Source
const ( HookBeforeDownload = "BeforeDownload" HookAfterDownload = "AfterDownload" HookAfterDownloadFailed = "AfterDownloadFailed" )
Variables ¶
This section is empty.
Functions ¶
func HookValidateFile ¶
func ValidateImageInfo ¶
func ValidateImageInfo(info ImageInfo, limit ImageLimit) error
Types ¶
type FileSystem ¶
type FileSystem struct {
// contains filtered or unexported fields
}
func NewFileSystem ¶
func NewFileSystem(policy core.StoragePolicy, opts ...Option) (*FileSystem, error)
func NewFromPolicy ¶
func NewFromPolicy(policy core.StoragePolicy, opts ...Option) (*FileSystem, error)
func (*FileSystem) CleanHooks ¶
func (fs *FileSystem) CleanHooks(name string)
func (*FileSystem) Close ¶
func (fs *FileSystem) Close() error
func (*FileSystem) Config ¶
func (fs *FileSystem) Config() core.Config
func (*FileSystem) Delete ¶
func (fs *FileSystem) Delete(paths ...string) error
func (*FileSystem) DispatchHandler ¶
func (fs *FileSystem) DispatchHandler() error
func (*FileSystem) Get ¶
func (fs *FileSystem) Get(path string) (io.ReadCloser, error)
func (*FileSystem) Handler ¶
func (fs *FileSystem) Handler() core.Handler
func (*FileSystem) InitUpload ¶
func (fs *FileSystem) InitUpload(ctx context.Context, req UploadInitRequest) (*core.UploadCredential, error)
func (*FileSystem) Put ¶
func (fs *FileSystem) Put(file core.FileHeader) error
func (*FileSystem) Recycle ¶
func (fs *FileSystem) Recycle()
func (*FileSystem) Token ¶
func (fs *FileSystem) Token(info core.FileInfo, ttl time.Duration) (*core.UploadCredential, error)
func (*FileSystem) Upload ¶
func (fs *FileSystem) Upload(ctx context.Context, file core.FileHeader) error
func (*FileSystem) UploadChunk ¶
func (fs *FileSystem) UploadChunk(ctx context.Context, uploadID string, index int, reader io.Reader) (*UploadChunkResult, error)
func (*FileSystem) UploadCroppedImage ¶
func (*FileSystem) UploadFromURL ¶
func (*FileSystem) UploadStatus ¶
func (fs *FileSystem) UploadStatus(uploadID string) (*UploadStatus, error)
func (*FileSystem) UploadStream ¶
func (*FileSystem) ValidateExtension ¶
func (fs *FileSystem) ValidateExtension(name, path string) bool
func (*FileSystem) ValidateFileInfo ¶
func (fs *FileSystem) ValidateFileInfo(file core.FileInfo) error
func (*FileSystem) ValidateFileName ¶
func (fs *FileSystem) ValidateFileName(name, path string) bool
func (*FileSystem) ValidateFileSize ¶
func (fs *FileSystem) ValidateFileSize(size int64) bool
type Option ¶
func WithAllowedExtensions ¶
func WithChunkSize ¶
func WithMaxSize ¶
func WithNameRules ¶
func WithTempDir ¶
func WithTokenTTL ¶
func WithUploadDir ¶
type UploadChunkResult ¶
type UploadChunkResult struct {
UploadID string `json:"upload_id"`
ChunkIndex int `json:"chunk_index"`
Received int `json:"received"`
ReceivedText string `json:"received_text"`
ChunkNum int `json:"chunk_num"`
Done bool `json:"done"`
FilePath string `json:"file_path"`
UploadComplete bool `json:"upload_complete"`
}
type UploadInitRequest ¶
type UploadSession ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.