Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterFileDownloader ¶
func RegisterFileDownloader(route httpx.Router, storage storage.Storage, options ...DownloaderOption)
RegisterFileDownloader registers a Gin route handler for file downloads from storage. It handles GET requests to serve files directly from the storage backend.
func RegisterFormFileUploader ¶
func RegisterFormFileUploader(route httpx.Router, storage storage.Storage, keyBuilder FileKeyBuilder, options ...UploadOption)
RegisterFormFileUploader registers a Gin route handler for form-based file uploads. It accepts multipart form uploads and stores files using the provided key builder.
Types ¶
type Config ¶
type Config struct {
PublicBase string `json:"public_base" yaml:"public_base"`
PutPrefix string `json:"put_prefix" yaml:"put_prefix"`
}
Config holds the configuration for S3 adapter operations.
type DownloaderOption ¶
type DownloaderOption func(o *downloaderOptions)
DownloaderOption configures file download behavior.
func WithCacheControl ¶
func WithCacheControl(maxAge uint64) DownloaderOption
WithCacheControl sets the Cache-Control header for downloaded files.
type FileKeyBuilder ¶
FileKeyBuilder generates storage keys from HTTP context and filenames. This allows customization of how uploaded files are named and organized.
type S3Adapter ¶
S3Adapter 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 NewS3Adapter ¶
NewS3Adapter creates a new S3 adapter with caching and upload token generation. It wraps an existing storage implementation to add temporary upload URL functionality.
func (*S3Adapter) GenerateUploadToken ¶
func (a *S3Adapter) GenerateUploadToken(ctx context.Context, fileName string, dir string, nameBuilder func(filename string, dir ...string) string) ([3]string, error)
GenerateUploadToken creates a temporary upload URL and token for client-side uploads. Returns the upload URL, final storage key, and public access URL.
func (*S3Adapter) RegisterFileDownloader ¶
func (a *S3Adapter) RegisterFileDownloader(route httpx.Router, options ...DownloaderOption)
func (*S3Adapter) RegisterPutFileUploader ¶
func (a *S3Adapter) RegisterPutFileUploader(route httpx.Router, options ...UploadOption)
RegisterPutFileUploader registers a Gin route handler for PUT-based file uploads. It handles temporary upload URLs generated by GenerateUploadToken and stores files using the original filename mapped from the temporary key.
type UploadOption ¶
type UploadOption func(*uploadOptions)
UploadOption configures file upload behavior and response handling.