upload

package
v0.12.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

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

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 {
	billy.Filesystem
	Write(path string, reader io.Reader, size int64) error
	ListFiles() ([]File, error)
}

Filesystem extends billy.Filesystem with additional utility methods

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 NewFilesystemMemory added in v0.8.0

func NewFilesystemMemory() Filesystem

NewFilesystemMemory creates a new in-memory filesystem instance

func NewFilesystemS3

func NewFilesystemS3(cfg S3Config) (Filesystem, error)

NewFilesystemS3 creates a new S3 filesystem instance with the specified configuration

type FilesystemLocal

type FilesystemLocal struct {
	billy.Filesystem
	// contains filtered or unexported fields
}

FilesystemLocal implements the Filesystem interface for local file storage using go-billy's osfs

func (*FilesystemLocal) ListFiles

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

ListFiles returns a list of all files in the filesystem

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

type FilesystemMemory added in v0.8.0

type FilesystemMemory struct {
	billy.Filesystem
}

FilesystemMemory implements the Filesystem interface for in-memory file storage using go-billy's memfs

func (*FilesystemMemory) ListFiles added in v0.8.0

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

ListFiles returns a list of all files in the filesystem

func (*FilesystemMemory) Write added in v0.8.0

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

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

type FilesystemS3

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

FilesystemS3 implements the billy.Filesystem interface for S3-compatible storage

func (*FilesystemS3) Chroot added in v0.8.0

func (fs *FilesystemS3) Chroot(path string) (billy.Filesystem, error)

Chroot creates a new filesystem rooted at the given path

func (*FilesystemS3) Create added in v0.8.0

func (fs *FilesystemS3) Create(filename string) (billy.File, error)

Create creates a new file for writing

func (*FilesystemS3) Join added in v0.8.0

func (fs *FilesystemS3) Join(elem ...string) string

Join joins path elements

func (*FilesystemS3) ListFiles

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

ListFiles returns a list of all files in the S3 bucket

func (*FilesystemS3) Lstat added in v0.8.0

func (fs *FilesystemS3) Lstat(filename string) (os.FileInfo, error)

Lstat returns file info (same as Stat for S3)

func (*FilesystemS3) MkdirAll added in v0.8.0

func (fs *FilesystemS3) MkdirAll(filename string, perm os.FileMode) error

MkdirAll creates all directories in the path (no-op for S3)

func (*FilesystemS3) Open

func (fs *FilesystemS3) Open(filename string) (billy.File, error)

Open opens a file for reading

func (*FilesystemS3) OpenFile added in v0.8.0

func (fs *FilesystemS3) OpenFile(filename string, flag int, perm os.FileMode) (billy.File, error)

OpenFile opens a file with the specified flag and permissions

func (*FilesystemS3) ReadDir added in v0.8.0

func (fs *FilesystemS3) ReadDir(dirPath string) ([]os.FileInfo, error)

ReadDir lists files in a directory

func (fs *FilesystemS3) Readlink(link string) (string, error)

Readlink is not supported on S3

func (*FilesystemS3) Remove added in v0.8.0

func (fs *FilesystemS3) Remove(filename string) error

Remove deletes a file

func (*FilesystemS3) Rename added in v0.8.0

func (fs *FilesystemS3) Rename(oldpath, newpath string) error

Rename renames a file (not efficiently supported in S3)

func (*FilesystemS3) Root added in v0.8.0

func (fs *FilesystemS3) Root() string

Root returns the root path of the filesystem

func (*FilesystemS3) Stat added in v0.8.0

func (fs *FilesystemS3) Stat(filename string) (os.FileInfo, error)

Stat returns file info for the specified path

func (fs *FilesystemS3) Symlink(target, link string) error

Symlink is not supported on S3

func (*FilesystemS3) TempFile added in v0.8.0

func (fs *FilesystemS3) TempFile(dir, prefix string) (billy.File, error)

TempFile creates a temporary file (not efficiently supported in S3)

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