s3

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	Name         string
	CreationDate time.Time
}

Bucket represents an S3 bucket.

type Client

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

Client wraps the S3 API for bucket and object operations.

func NewClient

func NewClient(cfg aws.Config) *Client

NewClient creates a new S3 client from the provided AWS config.

func (*Client) DownloadObject

func (c *Client) DownloadObject(ctx context.Context, bucket, key, destPath string) error

DownloadObject downloads an object to the specified destination path.

func (*Client) DownloadObjectWithProgress added in v0.1.3

func (c *Client) DownloadObjectWithProgress(ctx context.Context, bucket, key, destPath string, progress ProgressFunc) error

DownloadObjectWithProgress downloads an object with progress reporting.

func (*Client) GetBucketRegion

func (c *Client) GetBucketRegion(ctx context.Context, bucket string) (string, error)

GetBucketRegion returns the region for a bucket.

func (*Client) GetObjectDetails

func (c *Client) GetObjectDetails(ctx context.Context, bucket, key string) (*ObjectDetails, error)

GetObjectDetails retrieves extended metadata for an object.

func (*Client) GetObjectPreview

func (c *Client) GetObjectPreview(ctx context.Context, bucket, key string, maxBytes int64) ([]byte, string, error)

GetObjectPreview downloads up to maxBytes of an object and returns the content with its content type.

func (*Client) ListAllObjects added in v0.1.3

func (c *Client) ListAllObjects(ctx context.Context, bucket, prefix string) ([]Object, error)

ListAllObjects lists all objects under a prefix recursively (no delimiter). This is used for downloading entire folders.

func (*Client) ListBuckets

func (c *Client) ListBuckets(ctx context.Context) ([]Bucket, error)

ListBuckets returns all S3 buckets.

func (*Client) ListObjects

func (c *Client) ListObjects(ctx context.Context, bucket, prefix string, token *string) ([]Object, *string, error)

ListObjects returns objects and common prefixes in a bucket with the given prefix. Uses "/" as delimiter for folder-like navigation.

type Object

type Object struct {
	Key          string
	Name         string // display name (last path segment)
	Size         int64
	LastModified time.Time
	StorageClass string
	IsPrefix     bool // true for "folders"
}

Object represents an S3 object or prefix (folder).

type ObjectDetails

type ObjectDetails struct {
	Object
	ContentType string
	ETag        string
}

ObjectDetails contains extended metadata for an S3 object.

type ProgressFunc added in v0.1.3

type ProgressFunc func(bytesWritten, totalBytes int64)

ProgressFunc is called during download with bytes written and total size.

type S3API

type S3API interface {
	ListBuckets(ctx context.Context, params *s3.ListBucketsInput, optFns ...func(*s3.Options)) (*s3.ListBucketsOutput, error)
	ListObjectsV2(ctx context.Context, params *s3.ListObjectsV2Input, optFns ...func(*s3.Options)) (*s3.ListObjectsV2Output, error)
	HeadObject(ctx context.Context, params *s3.HeadObjectInput, optFns ...func(*s3.Options)) (*s3.HeadObjectOutput, error)
	GetObject(ctx context.Context, params *s3.GetObjectInput, optFns ...func(*s3.Options)) (*s3.GetObjectOutput, error)
	GetBucketLocation(ctx context.Context, params *s3.GetBucketLocationInput, optFns ...func(*s3.Options)) (*s3.GetBucketLocationOutput, error)
}

S3API captures the AWS SDK methods we use.

Jump to

Keyboard shortcuts

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