storage

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBucketNotFound      = errors.New("bucket not found")
	ErrBucketAlreadyExists = errors.New("bucket already exists")
	ErrObjectNotFound      = errors.New("object not found")
	ErrInvalidUploadID     = errors.New("invalid upload id")
	ErrInvalidPartNumber   = errors.New("invalid part number")
	ErrInvalidBucketName   = errors.New("invalid bucket name")
	ErrInvalidObjectKey    = errors.New("invalid object key")
	ErrChecksumMismatch    = errors.New("checksum mismatch")
	ErrInvalidRange        = errors.New("invalid byte range")
	ErrInvalidPart         = errors.New("invalid part")
	ErrUploadNotFound      = errors.New("upload not found")
)

Functions

This section is empty.

Types

type BucketInfo

type BucketInfo struct {
	Name    string
	ModTime time.Time
}

BucketInfo contains metadata about a bucket

type Metadata

type Metadata struct {
	CacheControl       string
	ContentDisposition string
	ContentType        string
	XAmzMeta           map[string]string
}

type Multipart added in v0.0.3

type Multipart struct {
	PartNumber     int
	ETag           string
	ChecksumSHA256 string
	ChecksumMD5    string
}

Multipart represents a part of a multipart upload

type MultipartUpload

type MultipartUpload struct {
	UploadID string
	Bucket   string
	Key      string
	ModTime  time.Time
}

MultipartUpload represents an in-progress multipart upload

type ObjectInfo

type ObjectInfo struct {
	Key            string
	Size           int64
	ETag           string
	ChecksumSHA256 string
	ChecksumMD5    string
	ModTime        time.Time
	Metadata       Metadata
}

ObjectInfo contains metadata about an object

type Part

type Part struct {
	PartNumber int
	ETag       string
	Size       int64
	ModTime    time.Time
}

Part represents a stored part of list parts

type Storage

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

Storage is the local filesystem storage backend

func NewStorage

func NewStorage(basePath string) (*Storage, error)

NewStorage creates a new local storage backend

func (*Storage) AbortMultipartUpload

func (s *Storage) AbortMultipartUpload(bucket, key, uploadID string) error

AbortMultipartUpload aborts a multipart upload

func (*Storage) BucketExists

func (s *Storage) BucketExists(bucket string) bool

BucketExists checks if a bucket exists

func (*Storage) Close added in v0.0.6

func (s *Storage) Close() error

Close closes the storage backend and releases resources

func (*Storage) CompleteMultipartUpload

func (s *Storage) CompleteMultipartUpload(bucket, key, uploadID string, parts []Multipart, expectedChecksumSHA256 string, expectedChecksumMD5 string) (*ObjectInfo, error)

CompleteMultipartUpload completes a multipart upload

func (*Storage) CopyObject

func (s *Storage) CopyObject(srcBucket, srcKey, dstBucket, dstKey string, replaceMetadata *Metadata) (*ObjectInfo, error)

CopyObject copies an object from one location to another

func (*Storage) CreateBucket

func (s *Storage) CreateBucket(bucket string) error

CreateBucket creates a new bucket

func (*Storage) DeleteBucket

func (s *Storage) DeleteBucket(bucket string) error

DeleteBucket deletes a bucket

func (*Storage) DeleteObject

func (s *Storage) DeleteObject(bucket, key string) error

DeleteObject deletes an object

func (*Storage) GetObject

func (s *Storage) GetObject(bucket, key string) (func() (io.ReadSeekCloser, error), *ObjectInfo, error)

GetObject retrieves an object

func (*Storage) InitiateMultipartUpload

func (s *Storage) InitiateMultipartUpload(bucket, key string, userMetadata Metadata) (string, error)

InitiateMultipartUpload initiates a multipart upload

func (*Storage) ListBuckets

func (s *Storage) ListBuckets(prefix, continuationToken string, maxBuckets int) (buckets []BucketInfo, nextContinuationToken string, err error)

ListBuckets lists all buckets with pagination support

func (*Storage) ListMultipartUploads

func (s *Storage) ListMultipartUploads(bucket, prefix, keyMarker, uploadIDMarker string, maxUploads int) (uploads []MultipartUpload, nextKeyMarker, nextUploadIDMarker string, err error)

ListMultipartUploads lists all in-progress multipart uploads with pagination support

func (*Storage) ListObjects

func (s *Storage) ListObjects(bucket, prefix, delimiter, marker string, maxKeys int) (objects []ObjectInfo, prefixes []string, nextContinuationToken string, err error)

ListObjects lists objects in a bucket with optional prefix, delimiter, and marker for pagination

func (*Storage) ListParts

func (s *Storage) ListParts(bucket, key, uploadID string, partNumberMarker string, maxParts int) (parts []Part, nextPartNumberMarker string, err error)

ListParts lists all uploaded parts for a multipart upload with pagination support

func (*Storage) PutObject

func (s *Storage) PutObject(bucket, key string, data io.Reader, userMetadata Metadata, expectedChecksumSHA256 string, expectedChecksumMD5 string) (*ObjectInfo, error)

PutObject stores an object If expectedChecksumSHA256 is provided (non-empty), it validates the checksum after computing. If expectedChecksumMD5 is provided (non-empty), it validates the MD5 checksum after computing.

func (*Storage) RenameObject

func (s *Storage) RenameObject(bucket, srcKey, dstKey string) error

RenameObject renames an object within the same bucket

func (*Storage) UploadPart

func (s *Storage) UploadPart(bucket, key, uploadID string, partNumber int, data io.Reader, expectedChecksumSHA256 string, expectedChecksumMD5 string) (*ObjectInfo, error)

UploadPart uploads a part of a multipart upload If expectedChecksumSHA256 is provided (non-empty), it validates the checksum after computing. If expectedChecksumMD5 is provided (non-empty), it validates the MD5 checksum after computing.

func (*Storage) UploadPartCopy

func (s *Storage) UploadPartCopy(bucket, key, uploadID string, partNumber int, srcBucket, srcKey string, startByte, endByte int64) (*ObjectInfo, error)

UploadPartCopy uploads a part of a multipart upload by copying from an existing object If startByte and endByte are both >= 0, only the specified byte range is copied. If startByte is < 0, the entire source object is copied.

Jump to

Keyboard shortcuts

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