s3

package
v1.33.3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package s3 provides a client to make API requests to Amazon Simple Storage Service.

Index

Constants

View Source
const (
	// EndpointsID is the ID to look up the S3 service endpoint.
	EndpointsID = s3.EndpointsID
)

Variables

This section is empty.

Functions

func FormatARN added in v1.14.0

func FormatARN(partition, location string) string

FormatARN formats an S3 object ARN. For example: arn:aws:s3:::stackset-myapp-infrastru-pipelinebuiltartifactbuc-1nk5t9zkymh8r.s3-us-west-2.amazonaws.com/scripts/dns-cert-validator/dd2278811c3

func Location added in v1.21.0

func Location(bucket, key string) string

Location returns an S3 object location URI in the format "s3://bucket/key".

func ParseARN added in v1.27.0

func ParseARN(arn string) (bucket, key string, err error)

ParseARN parses an S3 bucket or object ARN. For example, a bucket arn "arn:aws:s3:::my-bucket" returns "my-bucket", "", nil. Whereas, an object arn "arn:aws:s3:::my-bucket/key.json" returns "my-bucket, "key.json", nil

func ParseURL added in v1.5.0

func ParseURL(url string) (bucket string, key string, err error)

ParseURL parses URLs or s3 URIs and returns the bucket name and the optional key. For example, the URL: "https://stackset-myapp-infrastru-pipelinebuiltartifactbuc-1nk5t9zkymh8r.s3-us-west-2.amazonaws.com/scripts/dns-cert-validator/dd2278811c3" or alternatively, the s3 URI: "s3://stackset-myapp-infrastru-pipelinebuiltartifactbuc-1nk5t9zkymh8r/scripts/dns-cert-validator/dd2278811c3" Returns "stackset-myapp-infrastru-pipelinebuiltartifactbuc-1nk5t9zkymh8r" and "scripts/dns-cert-validator/dd2278811c3"

func URL added in v1.20.0

func URL(region, bucket, key string) string

URL returns a virtual-hosted–style S3 url for the object stored at key in a bucket created in the specified region.

Types

type CompressAndUploadFunc added in v1.4.0

type CompressAndUploadFunc func(key string, objects ...NamedBinary) (url string, err error)

CompressAndUploadFunc is invoked to zip multiple template contents and upload them to an S3 bucket under the specified key.

type NamedBinary added in v1.4.0

type NamedBinary interface {
	Name() string
	Content() []byte
}

NamedBinary is a named binary to be uploaded.

type S3

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

S3 wraps an Amazon Simple Storage Service client.

func New

func New(s *session.Session) *S3

New returns an S3 client configured against the input session.

func (*S3) BucketSizeAndCount added in v1.29.0

func (s *S3) BucketSizeAndCount(bucket string) (string, int, error)

BucketSizeAndCount returns the total size and number of objects in an S3 bucket.

func (*S3) BucketTree added in v1.29.0

func (s *S3) BucketTree(bucket string) (string, error)

BucketTree creates an ASCII tree representing the folder structure of a bucket's objects.

func (*S3) EmptyBucket

func (s *S3) EmptyBucket(bucket string) error

EmptyBucket deletes all objects within the bucket.

func (*S3) Upload added in v1.9.0

func (s *S3) Upload(bucket, key string, data io.Reader) (string, error)

Upload uploads a file to an S3 bucket under the specified key. Per s3's recommendation https://docs.aws.amazon.com/AmazonS3/latest/userguide/about-object-ownership.html: The bucket owner, in addition to the object owner, is granted full control.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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