s3

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 10 Imported by: 0

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

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.

type Disk

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

Disk implements filesystem.Disk against an S3-compatible store.

func New

func New(cfg Config) (*Disk, error)

New constructs a Disk. The bucket is NOT created here; ensure it exists out-of-band (e.g. with `mc mb` or the MinIO console).

func (*Disk) Copy

func (d *Disk) Copy(ctx context.Context, src, dst string) error

func (*Disk) Delete

func (d *Disk) Delete(ctx context.Context, p string) error

func (*Disk) Exists

func (d *Disk) Exists(ctx context.Context, p string) (bool, error)

func (*Disk) Files

func (d *Disk) Files(ctx context.Context, dir string) ([]filesystem.FileInfo, error)

func (*Disk) Get

func (d *Disk) Get(ctx context.Context, p string) ([]byte, error)

func (*Disk) Move

func (d *Disk) Move(ctx context.Context, src, dst string) error

func (*Disk) Put

func (d *Disk) Put(ctx context.Context, p string, data []byte) error

func (*Disk) PutStream

func (d *Disk) PutStream(ctx context.Context, p string, r io.Reader) error

func (*Disk) Reader

func (d *Disk) Reader(ctx context.Context, p string) (io.ReadCloser, error)

func (*Disk) Stat

func (d *Disk) Stat(ctx context.Context, p string) (filesystem.FileInfo, error)

Jump to

Keyboard shortcuts

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