s3

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GrantReadAllUsers is the constant used to give read access to all.
	GrantReadAllUsers = "uri=http://acs.amazonaws.com/groups/global/AllUsers"

	// DefaultRegion is a region to use if none are specified.
	DefaultRegion = "ca-central-1" // yul
)

Variables

This section is empty.

Functions

func PubURL

func PubURL(region, bucket, object string) string

PubURL returns the public URL for an object in a given region and bucket. This depends on you setting the appropriate permissions and choosing valid input parameters. No validation is done, this is just templating.

func Store

func Store(ctx context.Context, inputs *Inputs) (string, error)

Store takes some inputs and stores the data into s3. If successful, it returns a presign URL that can be shared to give access to the object. If you chose to make the object public, then it can also be accessed using the well-known public URL as obtained by the PubURL function. This depends on you having appropriate AWS credentials set up on your machine for the account you want to use.

Types

type Inputs

type Inputs struct {
	// Region is the region where we will push the data.
	Region string

	// BucketName is the name of the bucket.
	BucketName string

	// CreateBucket is true if we wish to create the bucket if it's missing.
	CreateBucket bool

	// ObjectName is the name of the object.
	ObjectName string

	// GrantReadAllUsers specifies that all users read access will be set on
	// this object. Only use this if you are certain you want anyone on the
	// internet to be able to read this object.
	GrantReadAllUsers bool

	// ContentType is what is set for the object if it is non-nil.
	ContentType *string

	// Data is the actual data to store.
	Data []byte

	Debug bool
	Logf  func(format string, v ...interface{})
}

Inputs is the set of information required to use the Store method.

Jump to

Keyboard shortcuts

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