Documentation
¶
Index ¶
Constants ¶
const ( // MetadataKeyOriginalFilename is the metadata key for storing the original filename // Note: MinIO canonicalizes metadata keys to Title-Case format (HTTP header standard). MetadataKeyOriginalFilename = "Original-Filename" // TempPrefix is the prefix for temporary object storage. // Files uploaded to temp/ should be promoted to permanent storage after business logic commits. TempPrefix = "temp/" )
Variables ¶
var ( // ErrBucketNotFound indicates the specified bucket does not exist. ErrBucketNotFound = errors.New("bucket not found") // ErrObjectNotFound indicates the specified object does not exist. ErrObjectNotFound = errors.New("object not found") // ErrInvalidBucketName indicates the bucket name is invalid. ErrInvalidBucketName = errors.New("invalid bucket name") // ErrInvalidObjectKey indicates the object key is invalid. ErrInvalidObjectKey = errors.New("invalid object key") // ErrAccessDenied indicates permission is denied for the operation. ErrAccessDenied = errors.New("access denied") // ErrProviderNotConfigured indicates no storage provider is configured. ErrProviderNotConfigured = errors.New("storage provider not configured") )
Functions ¶
This section is empty.
Types ¶
type CopyObjectOptions ¶
type CopyObjectOptions struct {
// SourceKey is the identifier of the source object
SourceKey string
// DestKey is the identifier for the copied object
DestKey string
}
CopyObjectOptions contains parameters for copying an object.
type DeleteObjectOptions ¶
type DeleteObjectOptions struct {
// Key is the unique identifier of the object to delete
Key string
}
DeleteObjectOptions contains parameters for deleting a single object.
type DeleteObjectsOptions ¶
type DeleteObjectsOptions struct {
// Keys is the list of object identifiers to delete
Keys []string
}
DeleteObjectsOptions contains parameters for batch deleting objects.
type GetObjectOptions ¶
type GetObjectOptions struct {
// Key is the unique identifier of the object
Key string
}
GetObjectOptions contains parameters for retrieving an object.
type ListObjectsOptions ¶
type ListObjectsOptions struct {
// Prefix filters objects by key prefix
Prefix string
// Recursive determines whether to list objects recursively
Recursive bool
// MaxKeys limits the maximum number of objects to return
MaxKeys int
}
ListObjectsOptions contains parameters for listing objects.
type MoveObjectOptions ¶
type MoveObjectOptions struct {
CopyObjectOptions
}
MoveObjectOptions contains parameters for moving an object.
type ObjectInfo ¶
type ObjectInfo struct {
// Bucket is the name of the storage bucket
Bucket string `json:"bucket"`
// Key is the unique identifier of the object within the bucket
Key string `json:"key"`
// ETag is the entity tag, typically an MD5 hash used for versioning and cache validation
ETag string `json:"eTag"`
// Size is the object size in bytes
Size int64 `json:"size"`
// ContentType is the MIME type of the object
ContentType string `json:"contentType"`
// LastModified is the timestamp when the object was last modified
LastModified time.Time `json:"lastModified"`
// Metadata contains custom key-value pairs associated with the object
Metadata map[string]string `json:"metadata,omitempty"`
}
ObjectInfo represents metadata information about a stored object.
type PresignedURLOptions ¶
type PresignedURLOptions struct {
// Key is the unique identifier of the object
Key string
// Expires specifies how long the presigned URL remains valid
Expires time.Duration
// Method specifies the HTTP method (GET for download, PUT for upload)
Method string
}
PresignedURLOptions contains parameters for generating presigned URLs.
type Provider ¶
type Provider interface {
// Setup initializes the storage provider (e.g., creating buckets, directories).
// This method should ONLY be called during application startup and MUST NOT be called at runtime.
Setup(ctx context.Context) error
// PutObject uploads an object to storage
PutObject(ctx context.Context, opts PutObjectOptions) (*ObjectInfo, error)
// GetObject retrieves an object from storage
GetObject(ctx context.Context, opts GetObjectOptions) (io.ReadCloser, error)
// DeleteObject deletes a single object from storage
DeleteObject(ctx context.Context, opts DeleteObjectOptions) error
// DeleteObjects deletes multiple objects from storage in a batch operation
DeleteObjects(ctx context.Context, opts DeleteObjectsOptions) error
// ListObjects lists objects in a bucket with optional filtering
ListObjects(ctx context.Context, opts ListObjectsOptions) ([]ObjectInfo, error)
// GetPresignedURL generates a presigned URL for temporary access to an object
GetPresignedURL(ctx context.Context, opts PresignedURLOptions) (string, error)
// CopyObject copies an object from source to destination
CopyObject(ctx context.Context, opts CopyObjectOptions) (*ObjectInfo, error)
// MoveObject moves an object from source to destination (implemented as Copy + Delete)
MoveObject(ctx context.Context, opts MoveObjectOptions) (*ObjectInfo, error)
// StatObject retrieves metadata information about an object
StatObject(ctx context.Context, opts StatObjectOptions) (*ObjectInfo, error)
// PromoteObject moves an object from temporary storage (temp/ prefix) to permanent storage.
// It removes the "temp/" prefix from the object key, effectively promoting a temporary upload
// to a permanent file. This is useful for handling multi-step upload workflows where files
// are initially uploaded to temp/ and only moved to permanent storage after business logic commits.
// If the key does not start with "temp/", this method does nothing and returns nil.
PromoteObject(ctx context.Context, tempKey string) (*ObjectInfo, error)
}
Provider defines the core interface for object storage operations. Implementations should support various cloud storage services like MinIO, S3, Aliyun OSS, Tencent COS, etc.
type PutObjectOptions ¶
type PutObjectOptions struct {
// Key is the unique identifier for the object
Key string
// Reader provides the object data to upload
Reader io.Reader
// Size is the size of the data in bytes (-1 if unknown)
Size int64
// ContentType specifies the MIME type of the object
ContentType string
// Metadata contains custom key-value pairs to store with the object
Metadata map[string]string
}
PutObjectOptions contains parameters for uploading an object.
type StatObjectOptions ¶
type StatObjectOptions struct {
// Key is the unique identifier of the object
Key string
}
StatObjectOptions contains parameters for retrieving object metadata.