upload

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STORAGE_MODE_LOCAL = "local"
	STORAGE_MODE_S3    = "s3"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	Name     string
	Size     int64
	MimeType string
}

type Filesystem

type Filesystem interface {
	Write(path string, reader io.Reader, size int64) error
	Open(path string) (io.ReadCloser, error)
	Delete(path string) error
	ListFiles() ([]File, error)
}

func CreateFilesystemFromEnv

func CreateFilesystemFromEnv() (Filesystem, error)

CreateFilesystemFromEnv creates a filesystem based on environment variables

func NewFilesystemLocal

func NewFilesystemLocal(basePath string) Filesystem

NewFilesystemLocal creates a new local filesystem instance with the specified base path

func NewFilesystemS3

func NewFilesystemS3(cfg S3Config) (Filesystem, error)

NewFilesystemS3 creates a new S3 filesystem instance with the specified configuration

type FilesystemLocal

type FilesystemLocal struct {
	// contains filtered or unexported fields
}

FilesystemLocal implements the Filesystem interface for local file storage

func (*FilesystemLocal) Delete

func (fs *FilesystemLocal) Delete(path string) error

Delete removes the file at the specified path

func (*FilesystemLocal) ListFiles

func (fs *FilesystemLocal) ListFiles() ([]File, error)

ListFiles returns a list of all files in the base path

func (*FilesystemLocal) Open

func (fs *FilesystemLocal) Open(path string) (io.ReadCloser, error)

Open opens a file at the specified path and returns a ReadCloser

func (*FilesystemLocal) Write

func (fs *FilesystemLocal) Write(path string, reader io.Reader, size int64) error

Write streams data from reader to a file at the specified path relative to the base path

type FilesystemS3

type FilesystemS3 struct {
	// contains filtered or unexported fields
}

FilesystemS3 implements the Filesystem interface for S3-compatible storage

func (*FilesystemS3) Delete

func (fs *FilesystemS3) Delete(path string) error

Delete removes a file from S3

func (*FilesystemS3) ListFiles

func (fs *FilesystemS3) ListFiles() ([]File, error)

ListFiles returns a list of all files in the S3 bucket

func (*FilesystemS3) Open

func (fs *FilesystemS3) Open(path string) (io.ReadCloser, error)

Open downloads a file from S3 and returns a ReadCloser

func (*FilesystemS3) Write

func (fs *FilesystemS3) Write(path string, reader io.Reader, size int64) error

Write streams data from reader to S3 at the specified path (key)

type S3Config

type S3Config struct {
	Endpoint        string // S3 endpoint URL (for S3-compatible services)
	Region          string // AWS region
	BucketName      string // S3 bucket name
	AccessKeyID     string // AWS access key ID
	SecretAccessKey string // AWS secret access key
	UseSSL          bool   // Whether to use SSL/TLS
}

S3Config holds the configuration for S3 filesystem

Jump to

Keyboard shortcuts

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