storage

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// S3DefaultPartSize is the default part size for S3 multipart uploads (10 MB).
	S3DefaultPartSize int64 = 10 * 1024 * 1024
	// S3MinPartSize is the minimum part size for S3 multipart uploads (5 MB).
	S3MinPartSize int64 = 5 * 1024 * 1024
	// S3MaxPartSize is the maximum part size for S3 multipart uploads (5 GiB).
	S3MaxPartSize int64 = 5 * 1024 * 1024 * 1024
)

Variables

View Source
var (
	ErrInvalidArgument = errors.New("invalid argument")
	ErrNotFound        = errors.New("object not found")
	ErrLockFailed      = errors.New("lock failed")
)
View Source
var (
	ErrFTPHostRequired = errors.New("FTP storage requires host")
)
View Source
var (
	ErrUnsupportedStorageType = errors.New("unsupported storage type")
)

Functions

This section is empty.

Types

type Backend added in v0.5.1

type Backend interface {
	// Upload uploads data to the specified path in the storage backend
	Upload(ctx context.Context, filename string, data io.Reader) error

	// Download downloads data from the specified path in the storage backend
	Download(ctx context.Context, filename string, data io.Writer) error

	// Delete removes a single object from the storage backend.
	Delete(ctx context.Context, filename string) error

	// List returns filenames available in the current backend prefix/path.
	List(ctx context.Context) ([]string, error)

	// UploadBytes uploads a small in-memory object to the backend.
	UploadBytes(ctx context.Context, filename string, data []byte) error

	// DownloadBytes downloads a small object from the backend into memory.
	DownloadBytes(ctx context.Context, filename string) ([]byte, error)

	// Lock locks a file in the storage backend, preventing concurrent writes.
	Lock(ctx context.Context, filename string) (Locker, error)

	// Close closes the storage backend and releases any resources.
	// Implementations that don't require cleanup should return nil.
	Close() error
}

Backend defines the interface for pluggable storage backends.

func New

func New(u *url.URL) (Backend, error)

New creates a new storage backend based on the configuration.

func NewFTPStorage added in v0.3.0

func NewFTPStorage(u *url.URL) (Backend, error)

func NewFilesystemStorage

func NewFilesystemStorage(u *url.URL) (Backend, error)

func NewS3Storage

func NewS3Storage(u *url.URL) (Backend, error)

type Locker added in v0.9.1

type Locker interface {
	Unlock(ctx context.Context) error
}

Jump to

Keyboard shortcuts

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