Documentation
¶
Overview ¶
Package s3 implements the filesystem.Disk interface against any S3-compatible object store: AWS S3, MinIO, DigitalOcean Spaces, Cloudflare R2, Wasabi, Backblaze B2 (S3 mode), Ceph RGW.
The driver is a separate Go module so the core lagodev module stays dependency-free:
go get github.com/devituz/lagodev/filesystem/s3@latest
Usage:
disk, err := s3.New(s3.Config{
Endpoint: "minio.local:9000", // host:port — no scheme
AccessKey: os.Getenv("S3_KEY"),
SecretKey: os.Getenv("S3_SECRET"),
Bucket: "uploads",
Region: "us-east-1",
UseSSL: false, // true for AWS S3, false for local MinIO
})
if err != nil { return err }
_ = disk.Put(ctx, "users/42/avatar.png", data)
MinIO note: MinIO speaks the same protocol as S3, so the same code works without changes; just point Endpoint at your MinIO host and set UseSSL to match how MinIO is exposed.
Index ¶
- type Config
- type Disk
- func (d *Disk) Copy(ctx context.Context, src, dst string) error
- func (d *Disk) Delete(ctx context.Context, p string) error
- func (d *Disk) Exists(ctx context.Context, p string) (bool, error)
- func (d *Disk) Files(ctx context.Context, dir string) ([]filesystem.FileInfo, error)
- func (d *Disk) Get(ctx context.Context, p string) ([]byte, error)
- func (d *Disk) Move(ctx context.Context, src, dst string) error
- func (d *Disk) Put(ctx context.Context, p string, data []byte) error
- func (d *Disk) PutStream(ctx context.Context, p string, r io.Reader) error
- func (d *Disk) Reader(ctx context.Context, p string) (io.ReadCloser, error)
- func (d *Disk) Stat(ctx context.Context, p string) (filesystem.FileInfo, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Endpoint is "host:port" (no scheme). For AWS S3 use
// "s3.us-east-1.amazonaws.com". For MinIO use "minio.local:9000"
// or wherever your instance listens.
Endpoint string
AccessKey string
SecretKey string
// Bucket is the bucket every operation is scoped to.
Bucket string
// Region for signing. Defaults to "us-east-1" — MinIO accepts this.
Region string
// UseSSL toggles HTTPS. AWS: true. MinIO over HTTP: false.
UseSSL bool
// Prefix optionally prepends a key prefix to every operation so
// multiple lagodev apps can share a bucket without colliding.
Prefix string
}
Config holds connection settings for an S3-compatible endpoint.
Click to show internal directories.
Click to hide internal directories.