fileserver

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

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) CopyFile added in v0.0.3

func (a *FileServer) CopyFile(ctx context.Context, sourceKey string, destinationKey string, overwrite bool) error

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 (a *FileServer) IsFileExists(ctx context.Context, key string) (bool, error)

func (*FileServer) MoveFile added in v0.0.3

func (a *FileServer) MoveFile(ctx context.Context, sourceKey string, destinationKey string, overwrite bool) error

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 (a *FileServer) UploadFile(ctx context.Context, file io.Reader, key string) (string, error)

func (*FileServer) UploadLocalFile added in v0.0.3

func (a *FileServer) UploadLocalFile(ctx context.Context, file string, key string) (string, error)

type Option added in v0.0.3

type Option func(*options)

Option configures file server behavior.

func WithCacheControl

func WithCacheControl(maxAge uint64) Option

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

type UploadResult struct {
	Key string `json:"key"`
	URL string `json:"url"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL