bfss3

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2018 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package bfss3 abstracts Amazon S3 bucket.

When imported, it registers a global `s3://` scheme resolver and can be used like:

import (
  "github.com/bsm/bfs"

  _ "github.com/bsm/bfs/bfsgs"
)

func main() {
  ctx := context.Background()

  u, _ := url.Parse("s3://bucket?prefix=custom%2Fprefix&acl=MY_ACL")
  bucket, _ := bfs.Resolve(ctx, u)

  f, _ := bucket.Open(ctx, "file/within/prefix.txt")
  ...
}

bfs.Resolve supports the following query parameters:

prefix                 - path prefix/namespace within the bucket
aws_access_key_id      - custom AWS credentials
aws_secret_access_key  - custom AWS credentials
aws_session_token      - custom AWS credentials
region                 - specify an AWS region
max_retries            - specify maximum number of retries
acl                    - custom ACL, defaults to DefaultACL

Index

Constants

View Source
const DefaultACL = "bucket-owner-full-control"

DefaultACL is the default ACL setting.

Variables

This section is empty.

Functions

func New

func New(bucket string, cfg *Config) (bfs.Bucket, error)

New initiates an bfs.Bucket backed by S3.

Types

type Config

type Config struct {
	// Native AWS configuration, used to create a Session,
	// unless one is already passed.
	AWS aws.Config
	// Custom ACL, defaults to DefaultACL.
	ACL string
	// An optional path prefix
	Prefix string
	// An optional custom session.
	// If nil, a new session will be created using the AWS config.
	Session *session.Session
}

Config is passed to New to configure the S3 connection.

Jump to

Keyboard shortcuts

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