s3

package module
v0.0.0-...-3f58919 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Endpoint

func Endpoint(endpoint string) func(*BucketOptions)

Endpoint set the endpoint option on the S3 connection.

func UseSSL

func UseSSL(useSSL bool) func(*BucketOptions)

UseSSL sets the SSL option on the S3 connection.

Types

type Bucket

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

Bucket implements methods for getting and putting s3 objects.

func NewBucket

func NewBucket(accessKeyID, secretAccessKey, region, bucketName string, optionFuncs ...func(*BucketOptions)) (*Bucket, error)

NewBucket returns a new Bucket instance. (It doesn't actually create a new bucket in S3.)

func (*Bucket) GetObject

func (b *Bucket) GetObject(objectName string) (*Object, error)

GetObject gets an object from S3.

func (*Bucket) PutObject

func (b *Bucket) PutObject(objectName string, contentType string, body io.Reader) error

PutObject puts an object into S3. Because the upstream s3 library wants a ReadSeeker, but we only require callers to provide the more flexible Reader, this function reads the whole body into memory to convert between the two. So don't use this for huge bodies (hundreds of MBs for example).

type BucketOptions

type BucketOptions struct {
	Endpoint string
	UseSSL   bool
}

type Object

type Object struct {
	io.ReadCloser
	ContentType   string
	ContentLength int
}

An Object represents a file on s3. It's not safe to read one from multiple goroutines.

Jump to

Keyboard shortcuts

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