driver

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: May 23, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package driver defines the interface for storage service implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket interface {
	CreateBucket(ctx context.Context, name string) error
	DeleteBucket(ctx context.Context, name string) error
	ListBuckets(ctx context.Context) ([]BucketInfo, error)

	PutObject(ctx context.Context, bucket, key string, data []byte, contentType string, metadata map[string]string) error
	GetObject(ctx context.Context, bucket, key string) (*Object, error)
	DeleteObject(ctx context.Context, bucket, key string) error
	HeadObject(ctx context.Context, bucket, key string) (*ObjectInfo, error)
	ListObjects(ctx context.Context, bucket string, opts ListOptions) (*ListResult, error)
	CopyObject(ctx context.Context, dstBucket, dstKey string, src CopySource) error

	// Presigned URLs
	GeneratePresignedURL(ctx context.Context, req PresignedURLRequest) (*PresignedURL, error)

	// Lifecycle policies
	PutLifecycleConfig(ctx context.Context, bucket string, config LifecycleConfig) error
	GetLifecycleConfig(ctx context.Context, bucket string) (*LifecycleConfig, error)
	EvaluateLifecycle(ctx context.Context, bucket string) ([]string, error)

	// Multipart uploads
	CreateMultipartUpload(ctx context.Context, bucket, key, contentType string) (*MultipartUpload, error)
	UploadPart(ctx context.Context, bucket, key, uploadID string, partNumber int, data []byte) (*UploadPart, error)
	CompleteMultipartUpload(ctx context.Context, bucket, key, uploadID string, parts []UploadPart) error
	AbortMultipartUpload(ctx context.Context, bucket, key, uploadID string) error
	ListMultipartUploads(ctx context.Context, bucket string) ([]MultipartUpload, error)

	// Versioning
	SetBucketVersioning(ctx context.Context, bucket string, enabled bool) error
	GetBucketVersioning(ctx context.Context, bucket string) (bool, error)

	// Bucket Policy
	PutBucketPolicy(ctx context.Context, bucket string, policy BucketPolicy) error
	GetBucketPolicy(ctx context.Context, bucket string) (*BucketPolicy, error)
	DeleteBucketPolicy(ctx context.Context, bucket string) error

	// CORS
	PutCORSConfig(ctx context.Context, bucket string, config CORSConfig) error
	GetCORSConfig(ctx context.Context, bucket string) (*CORSConfig, error)
	DeleteCORSConfig(ctx context.Context, bucket string) error

	// Encryption
	PutEncryptionConfig(ctx context.Context, bucket string, config EncryptionConfig) error
	GetEncryptionConfig(ctx context.Context, bucket string) (*EncryptionConfig, error)

	// Object Tagging
	PutObjectTagging(ctx context.Context, bucket, key string, tags map[string]string) error
	GetObjectTagging(ctx context.Context, bucket, key string) (map[string]string, error)
	DeleteObjectTagging(ctx context.Context, bucket, key string) error

	// Bucket Tagging
	PutBucketTagging(ctx context.Context, bucket string, tags map[string]string) error
	GetBucketTagging(ctx context.Context, bucket string) (map[string]string, error)
	DeleteBucketTagging(ctx context.Context, bucket string) error
}

Bucket is the interface that storage provider implementations must satisfy.

type BucketInfo

type BucketInfo struct {
	Name      string
	Region    string
	CreatedAt string
}

BucketInfo describes a storage bucket.

type BucketPolicy added in v1.3.1

type BucketPolicy struct {
	Version    string
	Statements []PolicyStatement
}

BucketPolicy represents a bucket access policy.

type CORSConfig added in v1.3.1

type CORSConfig struct {
	Rules []CORSRule
}

CORSConfig is a set of CORS rules for a bucket.

type CORSRule added in v1.3.1

type CORSRule struct {
	AllowedOrigins []string
	AllowedMethods []string
	AllowedHeaders []string
	ExposeHeaders  []string
	MaxAgeSeconds  int
}

CORSRule defines a CORS rule for a bucket.

type CopySource

type CopySource struct {
	Bucket string
	Key    string
}

CopySource identifies the source for a copy operation.

type EncryptionConfig added in v1.3.1

type EncryptionConfig struct {
	Enabled   bool
	Algorithm string // "AES256" or "aws:kms"
	KeyID     string // KMS key ID (optional)
}

EncryptionConfig describes the default encryption for a bucket.

type LifecycleConfig added in v1.2.0

type LifecycleConfig struct {
	Rules []LifecycleRule
}

LifecycleConfig is a set of lifecycle rules for a bucket.

type LifecycleRule added in v1.2.0

type LifecycleRule struct {
	ID                       string
	Enabled                  bool
	Prefix                   string
	ExpirationDays           int
	TransitionDays           int
	TransitionStorageClass   string
	AbortMultipartDays       int
	NoncurrentExpirationDays int
}

LifecycleRule defines an object lifecycle policy rule.

type ListOptions

type ListOptions struct {
	Prefix    string
	Delimiter string
	MaxKeys   int
	PageToken string
}

ListOptions configures a list operation.

type ListResult

type ListResult struct {
	Objects        []ObjectInfo
	CommonPrefixes []string
	NextPageToken  string
	IsTruncated    bool
}

ListResult is the result of a list operation.

type MultipartUpload added in v1.2.0

type MultipartUpload struct {
	UploadID  string
	Bucket    string
	Key       string
	CreatedAt string
}

MultipartUpload represents an in-progress multipart upload.

type Object

type Object struct {
	Info ObjectInfo
	Data []byte
}

Object is an object with its data.

type ObjectInfo

type ObjectInfo struct {
	Key          string
	Size         int64
	ContentType  string
	ETag         string
	LastModified string
	Metadata     map[string]string
}

ObjectInfo describes a stored object.

type PolicyStatement added in v1.3.1

type PolicyStatement struct {
	Effect    string   // "Allow" or "Deny"
	Principal string   // "*" or specific principal
	Actions   []string // e.g., "s3:GetObject"
	Resources []string // e.g., "arn:aws:s3:::bucket/*"
}

PolicyStatement represents a single statement in a bucket policy.

type PresignedURL added in v1.2.0

type PresignedURL struct {
	URL       string
	Method    string
	ExpiresAt time.Time
}

PresignedURL is a generated presigned URL.

type PresignedURLRequest added in v1.2.0

type PresignedURLRequest struct {
	Bucket    string
	Key       string
	Method    string // "GET" or "PUT"
	ExpiresIn time.Duration
}

PresignedURLRequest describes a presigned URL to generate.

type UploadPart added in v1.2.0

type UploadPart struct {
	PartNumber int
	ETag       string
	Size       int64
}

UploadPart represents a part of a multipart upload.

Jump to

Keyboard shortcuts

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