s3util

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: MIT Imports: 20 Imported by: 0

README

Documentation

Index

Constants

View Source
const (
	CredentialsTypeStatic = "static"

	DatacenterUSWest000 = "us-west-000" // https://github.com/peak/s5cmd/issues/269
	DatacenterUSWest002 = "us-west-002"

	BasePublicURL = "https://f000.backblazeb2.com/file"
)

Variables

View Source
var (
	ErrAWSSessionNotSet = errors.New("aws session not set")
	ErrS3ClientNotSet   = errors.New("s3 client not set")
	ErrS3UploaderNotSet = errors.New("s3 uploader not set")
	ErrBucketNotSet     = errors.New("bucket not set")
	ErrKeyNotSet        = errors.New("key not set")
)

Functions

func B2Endpoint

func B2Endpoint(region string) string

func DeleteObjectsInputFromKeys

func DeleteObjectsInputFromKeys(bucket string, keys []string, quiet bool) *s3.DeleteObjectsInput

func MSSToObjectIdentifiers

func MSSToObjectIdentifiers(m map[string]string) []*s3.ObjectIdentifier

MSSToObjectIdentifiers accepts a `map[string]string` of object info where keys are `ObjectIdentifier.Key` and the values are `ObjectIdentifier.VersionId`.`

func NewS3Client

func NewS3Client(cm config.AWSConfig) (*s3.S3, *session.Session, error)

func ObjectInputFile

func ObjectInputFile(filename string) (*s3.PutObjectInput, error)

func ObjectInputFileMore

func ObjectInputFileMore(bucket, key, filename string) (*s3.PutObjectInput, error)

func ObjectInputHTTPResponseMore

func ObjectInputHTTPResponseMore(bucket, key string, resp *http.Response) (*s3.PutObjectInput, error)

func ObjectKeyNameIsSafe

func ObjectKeyNameIsSafe(name string) bool

ObjectKeyNameIsSafe checks to see if all chars are within the safe characgter set. See more here: https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html

func UploadInputFile

func UploadInputFile(bucket, key, filename string) (*s3manager.UploadInput, error)

Types

type S3ClientMore

type S3ClientMore struct {
	Session    *session.Session
	S3Client   *s3.S3
	Downloader *s3manager.Downloader
	Uploader   *s3manager.Uploader
}

func NewS3ClientMore

func NewS3ClientMore(cm config.AWSConfig) (*S3ClientMore, error)

func NewS3ClientMoreSession

func NewS3ClientMoreSession(sess *session.Session) (*S3ClientMore, error)

func (*S3ClientMore) CreateBucketSimple

func (cm *S3ClientMore) CreateBucketSimple(bucket string) (*s3.CreateBucketOutput, error)

func (*S3ClientMore) DeleteObjectsByKeys

func (cm *S3ClientMore) DeleteObjectsByKeys(bucket string, keys []string, quiet bool) (*s3.DeleteObjectsOutput, error)

func (*S3ClientMore) ObjectFilePut

func (cm *S3ClientMore) ObjectFilePut(bucket, key, filename string) (*s3.PutObjectOutput, error)

func (*S3ClientMore) ObjectFileUpload

func (cm *S3ClientMore) ObjectFileUpload(bucket, key, filename string) (*s3manager.UploadOutput, error)

func (*S3ClientMore) ObjectFileUploadOld

func (cm *S3ClientMore) ObjectFileUploadOld(bucket, key, filename string) (*s3manager.UploadOutput, error)

func (*S3ClientMore) ObjectGetSimple

func (cm *S3ClientMore) ObjectGetSimple(bucket, key string) (*s3.GetObjectOutput, error)

ObjectGetSimple returns an object given a bucket and key. For more complex usage, usage a custom `s3.GetObjectInput`.

func (*S3ClientMore) ObjectGetToFile

func (cm *S3ClientMore) ObjectGetToFile(bucket, key, filename string) (int64, error)

func (*S3ClientMore) ObjectHTTPRequestPut

func (cm *S3ClientMore) ObjectHTTPRequestPut(bucket, key string, sreq httpsimple.Request, sclient *httpsimple.Client) (*s3.PutObjectOutput, error)

func (*S3ClientMore) ObjectHTTPRequestUpload

func (cm *S3ClientMore) ObjectHTTPRequestUpload(bucket, key string, sreq httpsimple.Request, sclient *httpsimple.Client) (*s3manager.UploadOutput, error)

func (*S3ClientMore) ObjectHTTPResponsePut

func (cm *S3ClientMore) ObjectHTTPResponsePut(bucket, key string, resp *http.Response) (*s3.PutObjectOutput, error)

func (*S3ClientMore) ObjectReaderUpload

func (cm *S3ClientMore) ObjectReaderUpload(bucket, key, contentType string, r io.Reader) (*s3manager.UploadOutput, error)

func (*S3ClientMore) ObjectStringPut

func (cm *S3ClientMore) ObjectStringPut(bucket, key, strBody string) (*s3.PutObjectOutput, error)

func (*S3ClientMore) ObjectsKeys

func (cm *S3ClientMore) ObjectsKeys(bucket, keypath string) ([]string, error)

iterate all objects in a given S3 bucket and prefix, sum up objects' total size in bytes use: size, err := S3ObjectsSize("example-bucket-name", "/a/b/c") this works if (a) keypath is empty, (b) keypath is a prefix, (c) keypath is a full key.

func (*S3ClientMore) ObjectsKeysPrint

func (cm *S3ClientMore) ObjectsKeysPrint(bucket, keypath string) ([]string, error)

func (*S3ClientMore) ObjectsSize

func (cm *S3ClientMore) ObjectsSize(bucket, keypath string) (int64, error)

ObjectsSize iterates all objects in a given S3 bucket and prefix to sum up objects' total size in bytes use: size, err := S3ObjectsSize("example-bucket-name", "/a/b/c")

func (*S3ClientMore) SetSession

func (cm *S3ClientMore) SetSession(sess *session.Session) error

Jump to

Keyboard shortcuts

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