Documentation
¶
Index ¶
- func ListBuckets(ctx context.Context, cfg aws.Config, opts S3Options) ([]string, error)
- type Backend
- type Checksummer
- type Copier
- type FileEntry
- type FileMetadata
- type GCSBackend
- func (b *GCSBackend) Copy(src, dst string) error
- func (b *GCSBackend) Delete(path string) error
- func (b *GCSBackend) GetMetadata(path string) (FileMetadata, error)
- func (b *GCSBackend) ID() string
- func (b *GCSBackend) ListDir(path string) ([]FileEntry, error)
- func (b *GCSBackend) Mkdir(path string) error
- func (b *GCSBackend) Read(path string) (io.ReadCloser, error)
- func (b *GCSBackend) Rename(oldPath, newPath string) error
- func (b *GCSBackend) Stat(path string) (FileEntry, error)
- func (b *GCSBackend) Write(path string, r io.Reader) error
- type GCSOptions
- type LocalBackend
- func (b *LocalBackend) Delete(path string) error
- func (b *LocalBackend) GetMetadata(path string) (FileMetadata, error)
- func (b *LocalBackend) ID() string
- func (b *LocalBackend) ListDir(path string) ([]FileEntry, error)
- func (b *LocalBackend) Mkdir(path string) error
- func (b *LocalBackend) Read(path string) (io.ReadCloser, error)
- func (b *LocalBackend) Rename(oldPath, newPath string) error
- func (b *LocalBackend) SetModTime(path string, modTime time.Time) error
- func (b *LocalBackend) Stat(path string) (FileEntry, error)
- func (b *LocalBackend) Write(path string, r io.Reader) error
- type ModTimeSetter
- type MultiBucketBackend
- func (m *MultiBucketBackend) Delete(path string) error
- func (m *MultiBucketBackend) GetMetadata(path string) (FileMetadata, error)
- func (b *MultiBucketBackend) ID() string
- func (m *MultiBucketBackend) ListDir(path string) ([]FileEntry, error)
- func (m *MultiBucketBackend) Mkdir(path string) error
- func (m *MultiBucketBackend) Read(path string) (io.ReadCloser, error)
- func (m *MultiBucketBackend) Rename(oldPath, newPath string) error
- func (m *MultiBucketBackend) Stat(path string) (FileEntry, error)
- func (m *MultiBucketBackend) Write(path string, r io.Reader) error
- type S3Backend
- func (b *S3Backend) Copy(src, dst string) error
- func (b *S3Backend) Delete(path string) error
- func (b *S3Backend) GetMetadata(path string) (FileMetadata, error)
- func (b *S3Backend) ID() string
- func (b *S3Backend) ListDir(path string) ([]FileEntry, error)
- func (b *S3Backend) Mkdir(path string) error
- func (b *S3Backend) Read(path string) (io.ReadCloser, error)
- func (b *S3Backend) Rename(oldPath, newPath string) error
- func (b *S3Backend) Stat(path string) (FileEntry, error)
- func (b *S3Backend) Write(path string, r io.Reader) error
- func (b *S3Backend) WriteWithSize(path string, r io.Reader, size int64) error
- type S3Options
- type SFTPBackend
- func (b *SFTPBackend) Close() error
- func (b *SFTPBackend) Delete(filePath string) error
- func (b *SFTPBackend) GetMetadata(path string) (FileMetadata, error)
- func (b *SFTPBackend) HomeDir() string
- func (b *SFTPBackend) ID() string
- func (b *SFTPBackend) ListDir(dirPath string) ([]FileEntry, error)
- func (b *SFTPBackend) Mkdir(dirPath string) error
- func (b *SFTPBackend) Read(filePath string) (io.ReadCloser, error)
- func (b *SFTPBackend) Rename(oldPath, newPath string) error
- func (b *SFTPBackend) SetModTime(filePath string, modTime time.Time) error
- func (b *SFTPBackend) Stat(filePath string) (FileEntry, error)
- func (b *SFTPBackend) Write(filePath string, r io.Reader) error
- type SFTPOptions
- type SizedWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Backend ¶
type Backend interface {
// ID returns a stable identifier for this backend instance (e.g. "s3://bucket",
// "sftp://host", "local:///path"). Two backends with the same ID can use
// server-side operations; different IDs require cross-backend copy.
ID() string
ListDir(path string) ([]FileEntry, error)
Stat(path string) (FileEntry, error)
Read(path string) (io.ReadCloser, error)
Write(path string, r io.Reader) error
Mkdir(path string) error
Delete(path string) error
Rename(oldPath, newPath string) error
GetMetadata(path string) (FileMetadata, error)
}
Backend is the common abstraction for S3, SFTP, and other storage backends.
type Checksummer ¶
Checksummer is an optional interface for backends that can provide content checksums without downloading the full file (e.g., S3 ETags).
type FileEntry ¶
type FileEntry struct {
Name string
Path string
Size int64
IsDir bool
Modified time.Time
Permissions string // e.g. "drwxr-xr-x" or "-rw-r--r--"
}
FileEntry represents a file or directory in any backend.
type FileMetadata ¶
type FileMetadata struct {
FileEntry
StorageClass string
ETag string
ContentType string
CustomMeta map[string]string
Tags map[string]string
Encryption string
VersionID string
}
FileMetadata holds extended file metadata for S3 objects.
type GCSBackend ¶
type GCSBackend struct {
// contains filtered or unexported fields
}
GCSBackend implements Backend for Google Cloud Storage.
func NewGCSBackend ¶
func NewGCSBackend(opts GCSOptions) (*GCSBackend, error)
NewGCSBackend creates a new GCS backend for the given bucket.
func (*GCSBackend) Copy ¶
func (b *GCSBackend) Copy(src, dst string) error
Copy performs a server-side copy within the same bucket.
func (*GCSBackend) Delete ¶
func (b *GCSBackend) Delete(path string) error
func (*GCSBackend) GetMetadata ¶
func (b *GCSBackend) GetMetadata(path string) (FileMetadata, error)
GetMetadata returns extended metadata for a GCS object.
func (*GCSBackend) ID ¶
func (b *GCSBackend) ID() string
func (*GCSBackend) Mkdir ¶
func (b *GCSBackend) Mkdir(path string) error
func (*GCSBackend) Read ¶
func (b *GCSBackend) Read(path string) (io.ReadCloser, error)
func (*GCSBackend) Rename ¶
func (b *GCSBackend) Rename(oldPath, newPath string) error
type GCSOptions ¶
type GCSOptions struct {
Bucket string
ProjectID string
CredentialsFile string
UseADC bool // default true — use Application Default Credentials
Endpoint string // optional custom/emulator endpoint
}
GCSOptions holds configuration for Google Cloud Storage clients.
type LocalBackend ¶
type LocalBackend struct {
// contains filtered or unexported fields
}
LocalBackend implements Backend for the local filesystem.
func NewLocalBackend ¶
func NewLocalBackend(root string) *LocalBackend
NewLocalBackend creates a local filesystem backend rooted at the given directory.
func (*LocalBackend) Delete ¶
func (b *LocalBackend) Delete(path string) error
func (*LocalBackend) GetMetadata ¶
func (b *LocalBackend) GetMetadata(path string) (FileMetadata, error)
func (*LocalBackend) ID ¶
func (b *LocalBackend) ID() string
func (*LocalBackend) Mkdir ¶
func (b *LocalBackend) Mkdir(path string) error
func (*LocalBackend) Read ¶
func (b *LocalBackend) Read(path string) (io.ReadCloser, error)
func (*LocalBackend) Rename ¶
func (b *LocalBackend) Rename(oldPath, newPath string) error
func (*LocalBackend) SetModTime ¶
func (b *LocalBackend) SetModTime(path string, modTime time.Time) error
SetModTime updates file timestamps for sync exact-timestamp semantics.
type ModTimeSetter ¶
ModTimeSetter is an optional interface for destinations that can preserve source modification timestamps after writes.
type MultiBucketBackend ¶
type MultiBucketBackend struct {
// contains filtered or unexported fields
}
MultiBucketBackend presents all buckets as top-level directories. Paths are formatted as "bucket-name/key".
func NewMultiBucketBackend ¶
func NewMultiBucketBackend(cfg aws.Config, buckets []string, opts S3Options) *MultiBucketBackend
NewMultiBucketBackend creates a backend that spans all given buckets.
func (*MultiBucketBackend) Delete ¶
func (m *MultiBucketBackend) Delete(path string) error
func (*MultiBucketBackend) GetMetadata ¶
func (m *MultiBucketBackend) GetMetadata(path string) (FileMetadata, error)
func (*MultiBucketBackend) ID ¶
func (b *MultiBucketBackend) ID() string
func (*MultiBucketBackend) ListDir ¶
func (m *MultiBucketBackend) ListDir(path string) ([]FileEntry, error)
func (*MultiBucketBackend) Mkdir ¶
func (m *MultiBucketBackend) Mkdir(path string) error
func (*MultiBucketBackend) Read ¶
func (m *MultiBucketBackend) Read(path string) (io.ReadCloser, error)
func (*MultiBucketBackend) Rename ¶
func (m *MultiBucketBackend) Rename(oldPath, newPath string) error
type S3Backend ¶
type S3Backend struct {
// contains filtered or unexported fields
}
S3Backend implements Backend for Amazon S3.
func NewS3Backend ¶
NewS3Backend creates a new S3 backend for the given bucket.
func (*S3Backend) GetMetadata ¶
func (b *S3Backend) GetMetadata(path string) (FileMetadata, error)
GetMetadata returns extended metadata for an S3 object.
type S3Options ¶
type S3Options struct {
Endpoint string
}
S3Options holds optional configuration for S3 clients.
type SFTPBackend ¶
type SFTPBackend struct {
// contains filtered or unexported fields
}
SFTPBackend implements Backend for SFTP remote filesystems.
func NewSFTPBackend ¶
func NewSFTPBackend(opts SFTPOptions) (*SFTPBackend, error)
NewSFTPBackend establishes an SSH connection and returns an SFTPBackend.
func (*SFTPBackend) Close ¶
func (b *SFTPBackend) Close() error
Close shuts down the SFTP client and underlying SSH connection.
func (*SFTPBackend) Delete ¶
func (b *SFTPBackend) Delete(filePath string) error
Delete removes a file or directory (recursively for directories).
func (*SFTPBackend) GetMetadata ¶
func (b *SFTPBackend) GetMetadata(path string) (FileMetadata, error)
GetMetadata returns metadata for an SFTP file.
func (*SFTPBackend) HomeDir ¶
func (b *SFTPBackend) HomeDir() string
HomeDir returns the absolute path of the remote user's home directory.
func (*SFTPBackend) ID ¶
func (b *SFTPBackend) ID() string
func (*SFTPBackend) ListDir ¶
func (b *SFTPBackend) ListDir(dirPath string) ([]FileEntry, error)
ListDir returns the contents of a remote directory.
func (*SFTPBackend) Mkdir ¶
func (b *SFTPBackend) Mkdir(dirPath string) error
Mkdir creates a remote directory and any necessary parents.
func (*SFTPBackend) Read ¶
func (b *SFTPBackend) Read(filePath string) (io.ReadCloser, error)
Read opens a remote file for reading.
func (*SFTPBackend) Rename ¶
func (b *SFTPBackend) Rename(oldPath, newPath string) error
Rename moves or renames a remote file or directory.
func (*SFTPBackend) SetModTime ¶
func (b *SFTPBackend) SetModTime(filePath string, modTime time.Time) error
SetModTime preserves source modification timestamps on SFTP destinations.