s3

package
v2.0.0-alpha.1+incompa... Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2015 License: Apache-2.0 Imports: 12 Imported by: 0

README

Docker-Registry S3 Storage Driver

An implementation of the storagedriver.StorageDriver interface which uses Amazon S3 for object storage.

Parameters

accesskey: Your aws access key.

secretkey: Your aws secret key.

Note You can provide empty strings for your access and secret keys if you plan on running the driver on an ec2 instance and will handle authentication with the instance's credentials.

region: The name of the aws region in which you would like to store objects (for example us-east-1). For a list of regions, you can look at http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html

bucket: The name of your s3 bucket where you wish to store objects (needs to already be created prior to driver initialization).

encrypt: (optional) Whether you would like your data encrypted on the server side (defaults to false if not specified).

secure: (optional) Whether you would like to transfer data to the bucket over ssl or not. Defaults to true (meaning transfering over ssl) if not specified. Note that while setting this to false will improve performance, it is not recommended due to security concerns.

v4auth: (optional) Whether you would like to use aws signature version 4 with your requests. This defaults to true if not specified (note that the eu-central-1 region does not work with version 2 signatures, so the driver will error out if initialized with this region and v4auth set to false)

chunksize: (optional) The default part size for multipart uploads (performed by WriteStream) to s3. The default is 10 MB. Keep in mind that the minimum part size for s3 is 5MB. You might experience better performance for larger chunk sizes depending on the speed of your connection to s3.

rootdirectory: (optional) The root directory tree in which all registry files will be stored. Defaults to the empty string (bucket root).

Documentation

Overview

Package s3 provides a storagedriver.StorageDriver implementation to store blobs in Amazon S3 cloud storage.

This package leverages the crowdmob/goamz client library for interfacing with s3.

Because s3 is a key, value store the Stat call does not support last modification time for directories (directories are an abstraction for key, value stores)

Keep in mind that s3 guarantees only eventual consistency, so do not assume that a successful write will mean immediate access to the data written (although in most regions a new object put has guaranteed read after write). The only true guarantee is that once you call Stat and receive a certain file size, that much of the file is already accessible.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver struct {
	S3            *s3.S3
	Bucket        *s3.Bucket
	ChunkSize     int64
	Encrypt       bool
	RootDirectory string
}

Driver is a storagedriver.StorageDriver implementation backed by Amazon S3 Objects are stored at absolute keys in the provided bucket

func FromParameters

func FromParameters(parameters map[string]interface{}) (*Driver, error)

FromParameters constructs a new Driver with a given parameters map Required parameters: - accesskey - secretkey - region - bucket - encrypt

func New

func New(params DriverParameters) (*Driver, error)

New constructs a new Driver with the given AWS credentials, region, encryption flag, and bucketName

func (*Driver) Delete

func (d *Driver) Delete(path string) error

Delete recursively deletes all objects stored at "path" and its subpaths.

func (*Driver) GetContent

func (d *Driver) GetContent(path string) ([]byte, error)

GetContent retrieves the content stored at "path" as a []byte.

func (*Driver) List

func (d *Driver) List(path string) ([]string, error)

List returns a list of the objects that are direct descendants of the given path.

func (*Driver) Move

func (d *Driver) Move(sourcePath string, destPath string) error

Move moves an object stored at sourcePath to destPath, removing the original object.

func (*Driver) PutContent

func (d *Driver) PutContent(path string, contents []byte) error

PutContent stores the []byte content at a location designated by "path".

func (*Driver) ReadStream

func (d *Driver) ReadStream(path string, offset int64) (io.ReadCloser, error)

ReadStream retrieves an io.ReadCloser for the content stored at "path" with a given byte offset.

func (*Driver) Stat

func (d *Driver) Stat(path string) (storagedriver.FileInfo, error)

Stat retrieves the FileInfo for the given path, including the current size in bytes and the creation time.

func (*Driver) URLFor

func (d *Driver) URLFor(path string, options map[string]interface{}) (string, error)

URLFor returns a URL which may be used to retrieve the content stored at the given path. May return an UnsupportedMethodErr in certain StorageDriver implementations.

func (*Driver) WriteStream

func (d *Driver) WriteStream(path string, offset int64, reader io.Reader) (totalRead int64, err error)

WriteStream stores the contents of the provided io.Reader at a location designated by the given path. The driver will know it has received the full contents when the reader returns io.EOF. The number of successfully READ bytes will be returned, even if an error is returned. May be used to resume writing a stream by providing a nonzero offset. Offsets past the current size will write from the position beyond the end of the file.

type DriverParameters

type DriverParameters struct {
	AccessKey     string
	SecretKey     string
	Bucket        string
	Region        aws.Region
	Encrypt       bool
	Secure        bool
	V4Auth        bool
	ChunkSize     int64
	RootDirectory string
}

DriverParameters A struct that encapsulates all of the driver parameters after all values have been set

Jump to

Keyboard shortcuts

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