gocloud.dev: gocloud.dev/blob/s3blob Index | Examples | Files

package s3blob

import "gocloud.dev/blob/s3blob"

Package s3blob provides a blob implementation that uses S3. Use OpenBucket to construct a blob.Bucket.

Open URLs

For blob.Open URLs, s3blob registers for the scheme "s3"; URLs start with "s3://".

The URL's Host is used as the bucket name. The AWS session is created as described in https://docs.aws.amazon.com/sdk-for-go/api/aws/session/. The following query options are supported:

- region: The AWS region for requests; sets aws.Config.Region.

Example URL:



s3blob exposes the following types for As:

- Bucket: *s3.S3
- Error: awserr.Error
- ListObject: s3.Object for objects, s3.CommonPrefix for "directories".
- ListOptions.BeforeList: *s3.ListObjectsV2Input
- Reader: s3.GetObjectOutput
- Attributes: s3.HeadObjectOutput
- WriterOptions.BeforeWrite: *s3manager.UploadInput


ctx := context.Background()

// Create an AWS session.
// This example uses defaults for finding credentials, which region to use,
// etc.
// See https://docs.aws.amazon.com/sdk-for-go/api/aws/session/
// for more info on available options.
sess, err := session.NewSession()
if err != nil {
    // Handle errror.

// Create a *blob.Bucket.
_, _ = s3blob.OpenBucket(ctx, sess, "my-bucket", nil)


_, _ = blob.Open(context.Background(), "s3://my-bucket")



Package Files


func OpenBucket Uses

func OpenBucket(ctx context.Context, sess client.ConfigProvider, bucketName string, opts *Options) (*blob.Bucket, error)

OpenBucket returns a *blob.Bucket backed by S3. See the package documentation for an example.

type Options Uses

type Options struct{}

Options sets options for constructing a *blob.Bucket backed by fileblob.

Package s3blob imports 19 packages (graph). Updated 2018-12-18. Refresh now. Tools for package owners.