s3blob

package module
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: BSD-3-Clause Imports: 12 Imported by: 43

README

gocloud-blob-s3

This is thing wrapper around the default go-cloud S3 blob opener to check for a credentials parameter (in blob URIs) and use it to assign AWS S3 session credentials.

Example

import (
	"context"
	"gocloud.dev/blob"
	_ "github.com/aaronland/gocloud-blob-s3"
)

func main() {

	ctx := context.Background()	
	bucket, _ := blob.OpenBucket(ctx, "s3blob://BUCKET?region=REGION&credentials=CREDENTIALS")

	// do stuff with bucket here
}

Note the use of the s3blob:// scheme which is different than the default s3:// scheme.

Credentials

Credentials for AWS sessions are defined as string labels. They are:

Label Description
env: Read credentials from AWS defined environment variables.
iam: Assume AWS IAM credentials are in effect.
{AWS_PROFILE_NAME} This this profile from the default AWS credentials location.
{AWS_CREDENTIALS_PATH}:{AWS_PROFILE_NAME} This this profile from a user-defined AWS credentials location.

See also

Documentation

Index

Constants

View Source
const Scheme = "s3blob"

Variables

This section is empty.

Functions

func NewWriterWithACL added in v0.2.0

func NewWriterWithACL(ctx context.Context, bucket *blob.Bucket, path string, acl string) (*blob.Writer, error)

NewWriterWithACL returns a new `blob.Writer` instance that has been configured with the relevant `blob.WriterOptions` to ensure that files written to S3 will be done using AWS ACL permissions defined in 'acl'.

func SetACLWriterOptionsWithContext

func SetACLWriterOptionsWithContext(ctx context.Context, key interface{}, acl string) context.Context

SetACLWriterOptionsWithContext return a new context.Context instance with a gocloud.dev/blob.WriterOptions instance used to assign 'acl' permissions for all S3 blob writes. The WriterOptions instance is assigned to the new context with key 'key' and is assumed to be retrieved later by code using blob.NewWriter instances. This method is DEPRECATED. Please use SetWriterOptionsWithContext() instead.

func SetWriterOptionsWithContext added in v0.1.1

func SetWriterOptionsWithContext(ctx context.Context, ctx_key interface{}, opt_key string, opt_value interface{}) (context.Context, error)

SetACLWriterOptionsWithContext return a new context.Context instance with a gocloud.dev/blob.WriterOptions instance whose properties are assigned according to 'opt_key' and 'opt_value', where the latter is a valid blob.WriterOptions property and the former is a valid type for that property. The one special-case is the "ACL" opt_key which which takes a opt_value of type type string and will assign a suitable GoCloud BeforeWrite option for assigning AWS S3 ACL permissions.

The WriterOptions instance is assigned to the new context with key 'ctx_key' and is assumed to be retrieved later by code using blob.NewWriter instances.

func SetWriterOptionsWithContextAndMap added in v0.1.2

func SetWriterOptionsWithContextAndMap(ctx context.Context, ctx_key interface{}, opts map[string]interface{}) (context.Context, error)

SetWriterOptionsWithContextAndMap is a convenience method for invoking SetWriterOptionsWithContext multiple times.

Types

type AsFunc added in v0.1.1

type AsFunc func(func(interface{}) bool) error

type URLOpener

type URLOpener struct {
	Session *aws_session.Session
}

func (*URLOpener) OpenBucketURL

func (o *URLOpener) OpenBucketURL(ctx context.Context, u *url.URL) (*blob.Bucket, error)

Jump to

Keyboard shortcuts

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