storage

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package storage provides a portable storage bucket API with cross-cutting concerns.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

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

Bucket is the portable storage type wrapping a driver with cross-cutting concerns.

func NewBucket

func NewBucket(d driver.Bucket, opts ...Option) *Bucket

NewBucket creates a new portable Bucket wrapping the given driver.

func (*Bucket) AbortMultipartUpload added in v1.2.0

func (b *Bucket) AbortMultipartUpload(ctx context.Context, bucket, key, uploadID string) error

AbortMultipartUpload aborts a multipart upload and removes all uploaded parts.

func (*Bucket) CompleteMultipartUpload added in v1.2.0

func (b *Bucket) CompleteMultipartUpload(
	ctx context.Context, bucket, key, uploadID string, parts []driver.UploadPart,
) error

CompleteMultipartUpload completes a multipart upload by assembling all parts.

func (*Bucket) CopyObject

func (b *Bucket) CopyObject(ctx context.Context, dstBucket, dstKey string, src driver.CopySource) error

CopyObject copies an object between buckets.

func (*Bucket) CreateBucket

func (b *Bucket) CreateBucket(ctx context.Context, name string) error

CreateBucket creates a new storage bucket.

func (*Bucket) CreateMultipartUpload added in v1.2.0

func (b *Bucket) CreateMultipartUpload(
	ctx context.Context, bucket, key, contentType string,
) (*driver.MultipartUpload, error)

CreateMultipartUpload initiates a multipart upload.

func (*Bucket) DeleteBucket

func (b *Bucket) DeleteBucket(ctx context.Context, name string) error

DeleteBucket deletes a storage bucket.

func (*Bucket) DeleteBucketPolicy added in v1.3.1

func (b *Bucket) DeleteBucketPolicy(ctx context.Context, bucket string) error

DeleteBucketPolicy removes the bucket policy.

func (*Bucket) DeleteBucketTagging added in v1.4.0

func (b *Bucket) DeleteBucketTagging(ctx context.Context, bucket string) error

DeleteBucketTagging removes all tags from a bucket.

func (*Bucket) DeleteCORSConfig added in v1.3.1

func (b *Bucket) DeleteCORSConfig(ctx context.Context, bucket string) error

DeleteCORSConfig removes the CORS configuration for a bucket.

func (*Bucket) DeleteObject

func (b *Bucket) DeleteObject(ctx context.Context, bucket, key string) error

DeleteObject deletes an object from a bucket.

func (*Bucket) DeleteObjectTagging added in v1.4.0

func (b *Bucket) DeleteObjectTagging(ctx context.Context, bucket, key string) error

DeleteObjectTagging removes all tags from an object.

func (*Bucket) EvaluateLifecycle added in v1.2.0

func (b *Bucket) EvaluateLifecycle(ctx context.Context, bucket string) ([]string, error)

EvaluateLifecycle evaluates lifecycle rules and returns keys eligible for expiration.

func (*Bucket) GeneratePresignedURL added in v1.2.0

func (b *Bucket) GeneratePresignedURL(ctx context.Context, req driver.PresignedURLRequest) (*driver.PresignedURL, error)

GeneratePresignedURL generates a presigned URL for an object.

func (*Bucket) GetBucketPolicy added in v1.3.1

func (b *Bucket) GetBucketPolicy(ctx context.Context, bucket string) (*driver.BucketPolicy, error)

GetBucketPolicy returns the bucket policy.

func (*Bucket) GetBucketTagging added in v1.4.0

func (b *Bucket) GetBucketTagging(ctx context.Context, bucket string) (map[string]string, error)

GetBucketTagging returns tags for a bucket.

func (*Bucket) GetBucketVersioning added in v1.2.0

func (b *Bucket) GetBucketVersioning(ctx context.Context, bucket string) (bool, error)

GetBucketVersioning returns whether versioning is enabled on a bucket.

func (*Bucket) GetCORSConfig added in v1.3.1

func (b *Bucket) GetCORSConfig(ctx context.Context, bucket string) (*driver.CORSConfig, error)

GetCORSConfig returns the CORS configuration for a bucket.

func (*Bucket) GetEncryptionConfig added in v1.3.1

func (b *Bucket) GetEncryptionConfig(ctx context.Context, bucket string) (*driver.EncryptionConfig, error)

GetEncryptionConfig returns the default encryption for a bucket.

func (*Bucket) GetLifecycleConfig added in v1.2.0

func (b *Bucket) GetLifecycleConfig(ctx context.Context, bucket string) (*driver.LifecycleConfig, error)

GetLifecycleConfig retrieves the lifecycle configuration for a bucket.

func (*Bucket) GetObject

func (b *Bucket) GetObject(ctx context.Context, bucket, key string) (*driver.Object, error)

GetObject retrieves an object from a bucket.

func (*Bucket) GetObjectTagging added in v1.4.0

func (b *Bucket) GetObjectTagging(ctx context.Context, bucket, key string) (map[string]string, error)

GetObjectTagging returns tags for an object.

func (*Bucket) HeadObject

func (b *Bucket) HeadObject(ctx context.Context, bucket, key string) (*driver.ObjectInfo, error)

HeadObject retrieves object metadata without the body.

func (*Bucket) ListBuckets

func (b *Bucket) ListBuckets(ctx context.Context) ([]driver.BucketInfo, error)

ListBuckets lists all buckets.

func (*Bucket) ListMultipartUploads added in v1.2.0

func (b *Bucket) ListMultipartUploads(ctx context.Context, bucket string) ([]driver.MultipartUpload, error)

ListMultipartUploads lists active multipart uploads for a bucket.

func (*Bucket) ListObjects

func (b *Bucket) ListObjects(ctx context.Context, bucket string, opts driver.ListOptions) (*driver.ListResult, error)

ListObjects lists objects in a bucket.

func (*Bucket) PutBucketPolicy added in v1.3.1

func (b *Bucket) PutBucketPolicy(ctx context.Context, bucket string, policy driver.BucketPolicy) error

PutBucketPolicy sets the bucket policy.

func (*Bucket) PutBucketTagging added in v1.4.0

func (b *Bucket) PutBucketTagging(ctx context.Context, bucket string, tags map[string]string) error

PutBucketTagging sets tags on a bucket.

func (*Bucket) PutCORSConfig added in v1.3.1

func (b *Bucket) PutCORSConfig(ctx context.Context, bucket string, cfg driver.CORSConfig) error

PutCORSConfig sets the CORS configuration for a bucket.

func (*Bucket) PutEncryptionConfig added in v1.3.1

func (b *Bucket) PutEncryptionConfig(ctx context.Context, bucket string, cfg driver.EncryptionConfig) error

PutEncryptionConfig sets the default encryption for a bucket.

func (*Bucket) PutLifecycleConfig added in v1.2.0

func (b *Bucket) PutLifecycleConfig(ctx context.Context, bucket string, config driver.LifecycleConfig) error

PutLifecycleConfig sets a lifecycle configuration on a bucket.

func (*Bucket) PutObject

func (b *Bucket) PutObject(ctx context.Context, bucket, key string, data []byte, contentType string, metadata map[string]string) error

PutObject stores an object in a bucket.

func (*Bucket) PutObjectTagging added in v1.4.0

func (b *Bucket) PutObjectTagging(ctx context.Context, bucket, key string, tags map[string]string) error

PutObjectTagging sets tags on an object.

func (*Bucket) SetBucketVersioning added in v1.2.0

func (b *Bucket) SetBucketVersioning(ctx context.Context, bucket string, enabled bool) error

SetBucketVersioning enables or disables versioning on a bucket.

func (*Bucket) UploadPart added in v1.2.0

func (b *Bucket) UploadPart(
	ctx context.Context, bucket, key, uploadID string, partNumber int, data []byte,
) (*driver.UploadPart, error)

UploadPart uploads a part of a multipart upload.

type Option

type Option func(*Bucket)

Option configures a portable Bucket.

func WithErrorInjection

func WithErrorInjection(i *inject.Injector) Option

WithErrorInjection sets the error injector.

func WithLatency

func WithLatency(d time.Duration) Option

WithLatency sets simulated latency.

func WithMetrics

func WithMetrics(m *metrics.Collector) Option

WithMetrics sets the metrics collector.

func WithRateLimiter

func WithRateLimiter(l *ratelimit.Limiter) Option

WithRateLimiter sets the rate limiter.

func WithRecorder

func WithRecorder(r *recorder.Recorder) Option

WithRecorder sets the recorder.

Directories

Path Synopsis
Package driver defines the interface for storage service implementations.
Package driver defines the interface for storage service implementations.

Jump to

Keyboard shortcuts

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