s3blob

package
v0.7.0 Latest Latest
Warning

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

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

Documentation

Overview

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:

s3://mybucket?region=us-east-1

As

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
Example
package main

import (
	"context"

	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/google/go-cloud/blob/s3blob"
)

func main() {
	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.
		return
	}

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

}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenBucket

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

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

Types

type Options added in v0.7.0

type Options struct{}

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

Jump to

Keyboard shortcuts

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