s3

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BucketMetrics

type BucketMetrics struct {
	Objects                       uint64
	ObjectsReadable               string
	ObjectsSize                   uint64
	ObjectsSizeReadable           string
	IncompleteObjects             uint64
	IncompleteObjectsReadable     string
	IncompleteObjectsSize         uint64
	IncompleteObjectsSizeReadable string
}

type Config added in v0.0.3

type Config struct {
	Endpoint             string
	Bucket               string
	Region               string
	AccessKey            string
	SecretKey            string
	Secure               bool
	PresignExpiry        time.Duration
	Timeout              time.Duration
	TransferTimeout      time.Duration
	MultipartPartSize    int64
	MultipartConcurrency int
}

Config holds all parameters needed to initialize an S3 connection.

type S3AO

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

func Init

func Init(cfg Config) (S3AO, error)

Initialize S3AO

func (S3AO) CopyObject

func (s S3AO) CopyObject(srcKey, dstKey string) error

CopyObject copies an object from one key to another within the same bucket

func (S3AO) GetBucket

func (s S3AO) GetBucket() string

GetBucket returns the bucket name

func (S3AO) GetBucketMetrics

func (s S3AO) GetBucketMetrics() (metrics BucketMetrics)

func (S3AO) GetClient

func (s S3AO) GetClient() *s3.Client

GetClient returns the underlying S3 client (for advanced operations)

func (S3AO) GetObject

func (s S3AO) GetObject(contentSHA256 string, start int64, end int64) (io.ReadCloser, error)

func (S3AO) GetObjectKey

func (s S3AO) GetObjectKey(bin string, filename string) (key string)

func (S3AO) GetObjectURL

func (s S3AO) GetObjectURL(contentSHA256 string) string

GetObjectURL returns the full S3 URL for a content SHA256

func (S3AO) ListObjects

func (s S3AO) ListObjects() (objects []string, err error)

func (S3AO) ListObjectsWithPrefix

func (s S3AO) ListObjectsWithPrefix(prefix string) ([]types.Object, error)

ListObjectsWithPrefix lists objects with a given prefix

func (S3AO) PresignedGetObject

func (s S3AO) PresignedGetObject(contentSHA256 string, filename string, mime string, clientIP string) (presignedURL *url.URL, err error)

PresignedGetObject generates a presigned URL for downloading an object. If clientIP is provided, the URL will require the X-Forwarded-For header to be set to that value when making the request (the header is included in the signature). This only works with objects that are not encrypted.

func (S3AO) PutObject

func (s S3AO) PutObject(bin string, filename string, data io.Reader, size int64) (err error)

func (S3AO) PutObjectByHash

func (s S3AO) PutObjectByHash(contentSHA256 string, data io.Reader, size int64) (err error)

PutObjectByHash uploads an object using content-addressable storage (SHA256 as key)

func (S3AO) RemoveBucket

func (s S3AO) RemoveBucket() error

func (S3AO) RemoveKey

func (s S3AO) RemoveKey(key string) error

func (S3AO) RemoveObject

func (s S3AO) RemoveObject(bin string, filename string) error

func (S3AO) RemoveObjectByHash

func (s S3AO) RemoveObjectByHash(contentSHA256 string) error

RemoveObjectByHash removes an object using content-addressable storage (SHA256 as key)

func (*S3AO) SetMetrics added in v0.0.3

func (s *S3AO) SetMetrics(m S3MetricsObserver)

SetMetrics sets the metrics observer for S3 operations.

func (S3AO) StatObject

func (s S3AO) StatObject(key string) (*s3.HeadObjectOutput, error)

StatObject checks if an object exists and returns its metadata

func (S3AO) Status

func (s S3AO) Status() bool

type S3MetricsObserver added in v0.0.3

type S3MetricsObserver interface {
	ObserveS3Operation(operation string, duration time.Duration)
	IncrS3OperationError(operation string)
}

S3MetricsObserver allows S3AO to report metrics without importing the ds package.

Jump to

Keyboard shortcuts

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