Documentation
¶
Index ¶
- Variables
- func CleanPath(p string) string
- func JoinPath(base string, elem ...string) string
- func ParseS3URI(uri string) (string, string, error)
- type FileInfo
- type LocalStorage
- func (s *LocalStorage) Close() error
- func (s *LocalStorage) Delete(_ context.Context, path string) error
- func (s *LocalStorage) Exists(_ context.Context, path string) (bool, error)
- func (s *LocalStorage) List(_ context.Context, prefix string) ([]FileInfo, error)
- func (s *LocalStorage) Read(_ context.Context, path string) ([]byte, error)
- func (s *LocalStorage) Write(_ context.Context, path string, data []byte) error
- type MemoryStorage
- func (s *MemoryStorage) Close() error
- func (s *MemoryStorage) Delete(_ context.Context, path string) error
- func (s *MemoryStorage) Exists(_ context.Context, path string) (bool, error)
- func (s *MemoryStorage) List(_ context.Context, prefix string) ([]FileInfo, error)
- func (s *MemoryStorage) Read(_ context.Context, path string) ([]byte, error)
- func (s *MemoryStorage) Write(_ context.Context, path string, data []byte) error
- type S3Options
- type S3Storage
- func (s *S3Storage) Close() error
- func (s *S3Storage) Delete(ctx context.Context, path string) error
- func (s *S3Storage) Exists(ctx context.Context, path string) (bool, error)
- func (s *S3Storage) List(ctx context.Context, prefix string) ([]FileInfo, error)
- func (s *S3Storage) Read(ctx context.Context, path string) ([]byte, error)
- func (s *S3Storage) Write(ctx context.Context, path string, data []byte) error
- type Storage
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("file not found") ErrAlreadyExists = errors.New("file already exists") ErrInvalidPath = errors.New("invalid storage path") ErrPermissionDenied = errors.New("permission denied") )
Standard sentinel storage errors.
Functions ¶
Types ¶
type FileInfo ¶
type FileInfo struct {
Path string `json:"path"`
Size int64 `json:"size"`
ModTime time.Time `json:"modTime"`
IsDir bool `json:"isDir"`
}
FileInfo represents metadata for an object or file in storage.
type LocalStorage ¶
type LocalStorage struct{}
LocalStorage implements Storage for the local OS filesystem.
func NewLocalStorage ¶
func NewLocalStorage() *LocalStorage
NewLocalStorage creates a new LocalStorage instance.
func (*LocalStorage) Close ¶
func (s *LocalStorage) Close() error
Close is a no-op for LocalStorage.
func (*LocalStorage) Delete ¶
func (s *LocalStorage) Delete(_ context.Context, path string) error
Delete removes a file or empty directory.
type MemoryStorage ¶
type MemoryStorage struct {
// contains filtered or unexported fields
}
MemoryStorage implements Storage in-memory for testing, benchmarking, and WASM runtime.
func NewMemoryStorage ¶
func NewMemoryStorage() *MemoryStorage
NewMemoryStorage creates a thread-safe MemoryStorage instance.
func (*MemoryStorage) Close ¶
func (s *MemoryStorage) Close() error
Close is a no-op for MemoryStorage.
func (*MemoryStorage) Delete ¶
func (s *MemoryStorage) Delete(_ context.Context, path string) error
Delete removes the file from memory.
type S3Options ¶
type S3Options struct {
Region string
Endpoint string
UsePathStyle bool
CustomHTTPClient aws.HTTPClient
}
S3Options allows configuring custom S3 endpoints, regions, or clients.
type S3Storage ¶
type S3Storage struct {
// contains filtered or unexported fields
}
S3Storage provides a zero-JVM native AWS S3 storage implementation.
func NewS3Storage ¶
NewS3Storage creates a new S3Storage instance with standard AWS credential discovery.
func NewS3StorageWithClient ¶
NewS3StorageWithClient initializes S3Storage with an existing S3 client.
type Storage ¶
type Storage interface {
// Read reads the entire content of the file at the specified path.
Read(ctx context.Context, path string) ([]byte, error)
// Write writes the given data to the specified path atomically.
Write(ctx context.Context, path string, data []byte) error
// List lists all files and directories matching the prefix.
List(ctx context.Context, prefix string) ([]FileInfo, error)
// Exists checks if an object or directory exists at path.
Exists(ctx context.Context, path string) (bool, error)
// Delete deletes the file or object at path.
Delete(ctx context.Context, path string) error
// Close releases any open network connections or resources.
Close() error
}
Storage defines the unified storage interface across Local FS, Amazon S3, Google GCS, Azure Blob, and Memory.
func NewStorageForPath ¶
NewStorageForPath automatically resolves and instantiates the appropriate Storage implementation for a path URI.