Documentation
¶
Index ¶
- type Config
- type FileServer
- func (a *FileServer) CopyFile(ctx context.Context, sourceKey string, destinationKey string, overwrite bool) error
- func (a *FileServer) DeleteFile(ctx context.Context, key string) error
- func (a *FileServer) DownloadFile(ctx context.Context, key string) (storage.DownloadResult, error)
- func (a *FileServer) ExtractKeyFromURL(uri string) string
- func (a *FileServer) ExtractKeyFromURLWithMode(uri string, strict bool) (string, error)
- func (a *FileServer) GenerateURL(key string, params ...url.Values) string
- func (a *FileServer) GenerateURLs(keys []string, params ...url.Values) []string
- func (a *FileServer) GenerateUploadAuth(ctx context.Context, req storage.UploadAuthRequest) (storage.UploadAuthResult, error)
- func (a *FileServer) IsFileExists(ctx context.Context, key string) (bool, error)
- func (a *FileServer) MoveFile(ctx context.Context, sourceKey string, destinationKey string, overwrite bool) error
- func (a *FileServer) RegisterFileDownloader(route httpx.Router)
- func (a *FileServer) RegisterFileUploader(route httpx.Router)
- func (a *FileServer) UploadFile(ctx context.Context, file io.Reader, key string) (string, error)
- func (a *FileServer) UploadLocalFile(ctx context.Context, file string, key string) (string, error)
- type Option
- type UploadResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
PutBase string `json:"put_base" yaml:"put_base"`
GetBase string `json:"get_base" yaml:"get_base"`
KeyTTL time.Duration `json:"key_ttl" yaml:"key_ttl"`
Dir string `json:"dir" yaml:"dir"`
UploadNaming storage.UploadNamingStrategy `json:"upload_naming" yaml:"upload_naming"`
}
Config holds the configuration for S3 adapter operations.
type FileServer ¶ added in v0.0.3
type FileServer struct {
// contains filtered or unexported fields
}
FileServer provides a caching layer and upload token generation for S3-compatible storage. It extends a base storage implementation with temporary upload URL generation capabilities.
func NewCDNAdapter ¶ added in v0.0.3
func NewCDNAdapter(conf Config, cache cache.ByteCache, store storage.Storage, options ...Option) (*FileServer, error)
NewCDNAdapter creates a new CDN adapter with URL and token generation capabilities.
func (*FileServer) DeleteFile ¶ added in v0.0.3
func (a *FileServer) DeleteFile(ctx context.Context, key string) error
func (*FileServer) DownloadFile ¶ added in v0.0.3
func (a *FileServer) DownloadFile(ctx context.Context, key string) (storage.DownloadResult, error)
func (*FileServer) ExtractKeyFromURL ¶ added in v0.0.3
func (a *FileServer) ExtractKeyFromURL(uri string) string
func (*FileServer) ExtractKeyFromURLWithMode ¶ added in v0.0.3
func (a *FileServer) ExtractKeyFromURLWithMode(uri string, strict bool) (string, error)
func (*FileServer) GenerateURL ¶ added in v0.0.3
func (a *FileServer) GenerateURL(key string, params ...url.Values) string
func (*FileServer) GenerateURLs ¶ added in v0.0.3
func (a *FileServer) GenerateURLs(keys []string, params ...url.Values) []string
func (*FileServer) GenerateUploadAuth ¶ added in v0.0.3
func (a *FileServer) GenerateUploadAuth(ctx context.Context, req storage.UploadAuthRequest) (storage.UploadAuthResult, error)
GenerateUploadAuth creates temporary upload authorization for client-side uploads.
func (*FileServer) IsFileExists ¶ added in v0.0.3
func (*FileServer) RegisterFileDownloader ¶ added in v0.0.3
func (a *FileServer) RegisterFileDownloader(route httpx.Router)
func (*FileServer) RegisterFileUploader ¶ added in v0.0.3
func (a *FileServer) RegisterFileUploader(route httpx.Router)
func (*FileServer) UploadFile ¶ added in v0.0.3
func (*FileServer) UploadLocalFile ¶ added in v0.0.3
type Option ¶ added in v0.0.3
type Option func(*options)
Option configures file server behavior.
func WithCacheControl ¶
WithCacheControl sets the Cache-Control header for downloaded files.
func WithCreateFileKey ¶ added in v0.0.3
func WithCreateFileKey(fn func(ctx context.Context, server *FileServer, filename string) (string, error)) Option
WithCreateFileKey customizes temporary upload key generation behavior.
type UploadResult ¶ added in v0.0.3
Click to show internal directories.
Click to hide internal directories.