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 ¶
- type S3Driver
- func (d *S3Driver) AbortMultipart(ctx context.Context, bucket, key, uploadID string) error
- func (d *S3Driver) Client() *s3.Client
- func (d *S3Driver) Close(_ context.Context) error
- func (d *S3Driver) CompleteMultipart(ctx context.Context, bucket, key, uploadID string, parts []driver.PartInfo) (*driver.ObjectInfo, error)
- func (d *S3Driver) Copy(ctx context.Context, srcBucket, srcKey, dstBucket, dstKey string, ...) (*driver.ObjectInfo, error)
- func (d *S3Driver) CreateBucket(ctx context.Context, name string, opts ...driver.BucketOption) error
- func (d *S3Driver) Delete(ctx context.Context, bucket, key string, _ ...driver.DeleteOption) error
- func (d *S3Driver) DeleteBucket(ctx context.Context, name string) error
- func (d *S3Driver) Get(ctx context.Context, bucket, key string, opts ...driver.GetOption) (*driver.ObjectReader, error)
- func (d *S3Driver) GetRange(ctx context.Context, bucket, key string, offset, length int64) (*driver.ObjectReader, error)
- func (d *S3Driver) Head(ctx context.Context, bucket, key string) (*driver.ObjectInfo, error)
- func (d *S3Driver) InitiateMultipart(ctx context.Context, bucket, key string, opts ...driver.PutOption) (string, error)
- func (d *S3Driver) List(ctx context.Context, bucket string, opts ...driver.ListOption) (*driver.ObjectIterator, error)
- func (d *S3Driver) ListBuckets(ctx context.Context) ([]driver.BucketInfo, error)
- func (d *S3Driver) Name() string
- func (d *S3Driver) Open(ctx context.Context, dsn string, opts ...driver.Option) error
- func (d *S3Driver) Ping(ctx context.Context) error
- func (d *S3Driver) PresignGet(ctx context.Context, bucket, key string, expires time.Duration) (string, error)
- func (d *S3Driver) PresignPut(ctx context.Context, bucket, key string, expires time.Duration) (string, error)
- func (d *S3Driver) Put(ctx context.Context, bucket, key string, r io.Reader, opts ...driver.PutOption) (*driver.ObjectInfo, error)
- func (d *S3Driver) UploadPart(ctx context.Context, bucket, key, uploadID string, partNum int, r io.Reader) (*driver.PartInfo, error)
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 (*S3Driver) AbortMultipart ¶
AbortMultipart cancels a multipart upload.
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) DeleteBucket ¶
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) 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 ¶
ListBuckets returns all accessible buckets.
func (*S3Driver) Ping ¶
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.