s3client

package
v0.0.0-...-550751b Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package s3client is a wrapper around the AWS S3 connection.

Package s3client is a wrapper around the AWS S3 connection.

Index

Constants

View Source
const (
	// DefaultMultipartChunkSize is the max size of a multipart chunk.
	DefaultMultipartChunkSize int64 = 1024 * 1024 * 100 // 100Mb chunk for multipart upload by default.

)

Variables

View Source
var (
	ErrPathNoBucketSeparator = errors.New("no bucket separator in S3 path")
	ErrPathNoKey             = errors.New("no key in S3 path")
)

Functions

This section is empty.

Types

type BucketClient

type BucketClient interface {
	Exists(key string) (bool, error)
	GetSize(key string, callerPays bool) (int64, error)
	GetObject(key string, callerPays bool) ([]byte, error)
	Delete(key string) error
	Copy(src, dst string, validateEtag, callerPays bool) error
	IsSrcNewer(src, dst string, callerPays bool) (bool, error)
	GetPresignedURL(key string, duration time.Duration) (string, error)
	GetETag(key string) (string, error)
}

func NewBucketClient

func NewBucketClient(s3 *s3.S3, bucket string) BucketClient

NewBucketClient returns a new S3Bucket

func NewBucketClientWithClient

func NewBucketClientWithClient(client S3Client, bucket string) BucketClient

NewBucketClientWithClient creates a new bucket's client using S3Client interface.

type S3Client

type S3Client interface {
	CreateBucket(bucket string) (string, error)
	Exists(obj S3Path) (bool, error)
	GetSize(obj S3Path, callerPays bool) (int64, error)
	GetObject(objPath S3Path, callerPays bool) ([]byte, error)
	Delete(obj S3Path) error
	Copy(src, dst S3Path, validateEtag, callerPays bool) error
	IsSrcNewer(src, dst S3Path, callerPays bool) (bool, error)
	GetPresignedURL(obj S3Path, duration time.Duration) (string, error)
	GetETag(obj S3Path) (string, error)
}

S3Client is a client for AWS S3 storage.

func NewClientFromS3

func NewClientFromS3(awsS3client *s3.S3) S3Client

NewClientFromS3 sets the AWS S3 connection and returns an S3Client interface.

type S3Path

type S3Path struct {
	Bucket string
	Key    string
}

S3Path contains a ful path to a bucket object.

func NewS3Object

func NewS3Object(path string) (S3Path, error)

NewS3Object creates a path object from a path: [bucket]/[key].

func (*S3Path) FullPath

func (p *S3Path) FullPath() string

FullPath returns a full S3 path constructed including the schema.

func (*S3Path) Path

func (p *S3Path) Path() string

Path returns an S3 path constructed.

Jump to

Keyboard shortcuts

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