s3driver

package module
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package s3driver provides an Amazon S3 and S3-compatible storage driver for Trove.

The S3 driver stores objects in Amazon S3 or any S3-compatible service (MinIO, DigitalOcean Spaces, Backblaze B2, etc.). It implements the core driver.Driver interface plus MultipartDriver, PresignDriver, and RangeDriver capability interfaces.

DSN format:

s3://REGION/BUCKET
s3://ACCESS_KEY:SECRET@REGION/BUCKET?endpoint=http://localhost:9000&path_style=true

Usage:

drv := s3driver.New()
drv.Open(ctx, "s3://us-east-1/my-bucket")
t, err := trove.Open(drv)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type S3Driver

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

S3Driver implements driver.Driver for Amazon S3 and S3-compatible stores.

func New

func New() *S3Driver

New creates a new S3 storage driver.

func Unwrap

func Unwrap(t interface{ Driver() driver.Driver }) *S3Driver

Unwrap extracts the typed S3Driver from a Trove handle.

func (*S3Driver) AbortMultipart

func (d *S3Driver) AbortMultipart(ctx context.Context, bucket, key, uploadID string) error

AbortMultipart cancels a multipart upload.

func (*S3Driver) Client

func (d *S3Driver) Client() *s3.Client

Client returns the underlying S3 client for advanced use cases.

func (*S3Driver) Close

func (d *S3Driver) Close(_ context.Context) error

Close marks the driver as closed.

func (*S3Driver) CompleteMultipart

func (d *S3Driver) CompleteMultipart(ctx context.Context, bucket, key, uploadID string, parts []driver.PartInfo) (*driver.ObjectInfo, error)

CompleteMultipart completes a multipart upload.

func (*S3Driver) Copy

func (d *S3Driver) Copy(ctx context.Context, srcBucket, srcKey, dstBucket, dstKey string, _ ...driver.CopyOption) (*driver.ObjectInfo, error)

Copy copies an object within or across buckets.

func (*S3Driver) CreateBucket

func (d *S3Driver) CreateBucket(ctx context.Context, name string, opts ...driver.BucketOption) error

CreateBucket creates a new S3 bucket.

func (*S3Driver) Delete

func (d *S3Driver) Delete(ctx context.Context, bucket, key string, _ ...driver.DeleteOption) error

Delete removes an object from S3.

func (*S3Driver) DeleteBucket

func (d *S3Driver) DeleteBucket(ctx context.Context, name string) error

DeleteBucket removes an S3 bucket.

func (*S3Driver) Get

func (d *S3Driver) Get(ctx context.Context, bucket, key string, opts ...driver.GetOption) (*driver.ObjectReader, error)

Get retrieves an object from S3.

func (*S3Driver) GetRange

func (d *S3Driver) GetRange(ctx context.Context, bucket, key string, offset, length int64) (*driver.ObjectReader, error)

GetRange retrieves a byte range of an object. The offset is the starting byte position and length is the number of bytes to read. A length of -1 reads from offset to end.

func (*S3Driver) Head

func (d *S3Driver) Head(ctx context.Context, bucket, key string) (*driver.ObjectInfo, error)

Head returns object metadata without content.

func (*S3Driver) InitiateMultipart

func (d *S3Driver) InitiateMultipart(ctx context.Context, bucket, key string, opts ...driver.PutOption) (string, error)

InitiateMultipart starts a multipart upload and returns the upload ID.

func (*S3Driver) List

func (d *S3Driver) List(ctx context.Context, bucket string, opts ...driver.ListOption) (*driver.ObjectIterator, error)

List returns objects matching the given options.

func (*S3Driver) ListBuckets

func (d *S3Driver) ListBuckets(ctx context.Context) ([]driver.BucketInfo, error)

ListBuckets returns all accessible buckets.

func (*S3Driver) Name

func (d *S3Driver) Name() string

Name returns "s3".

func (*S3Driver) Open

func (d *S3Driver) Open(ctx context.Context, dsn string, opts ...driver.Option) error

Open initializes the S3 client using the given DSN and options.

func (*S3Driver) Ping

func (d *S3Driver) Ping(ctx context.Context) error

Ping verifies connectivity by performing a HeadBucket on the configured bucket.

func (*S3Driver) PresignGet

func (d *S3Driver) PresignGet(ctx context.Context, bucket, key string, expires time.Duration) (string, error)

PresignGet generates a pre-signed URL for downloading an object.

func (*S3Driver) PresignPut

func (d *S3Driver) PresignPut(ctx context.Context, bucket, key string, expires time.Duration) (string, error)

PresignPut generates a pre-signed URL for uploading an object.

func (*S3Driver) Put

func (d *S3Driver) Put(ctx context.Context, bucket, key string, r io.Reader, opts ...driver.PutOption) (*driver.ObjectInfo, error)

Put stores an object in S3.

func (*S3Driver) UploadPart

func (d *S3Driver) UploadPart(ctx context.Context, bucket, key, uploadID string, partNum int, r io.Reader) (*driver.PartInfo, error)

UploadPart uploads a single part of a multipart upload.

Jump to

Keyboard shortcuts

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