googlestorage

package
Version: v0.0.0-...-7a1a713 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2013 License: Apache-2.0 Imports: 9 Imported by: 0

README

Implements the Storage interface for Google Storage.
A GoogleStorage instance stores blobs in a single Google Storage bucket, with
each blob keyed by its blobref.  

Testing:

gsapi_test.go contains integration tests which run against Google Storage.
In order to run these tests properly, you will need to:

1.  Set up google storage.  See:
	http://code.google.com/apis/storage/docs/signup.html

2.  Upload the contents of the testdata dir to a google storage bucket.  Note
	that all these files begin with 'test-': such files will be ignored when 
	the bucket is used as blobserver storage.

3.  Create the config file '~/.camli/gstestconfig.json'.  The file should look
	something like this:

	{
			"auth": {
				"client_id": "your client id",
				"client_secret": "your client secret",
				"refresh_token": "a refresh token"
			},
			"bucket": "bucket.example.com"
	}

	You can use camgsinit to help obtain the auth config object.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(transport *oauth.Transport) *Client

func (*Client) DeleteObject

func (gsa *Client) DeleteObject(obj *Object) (err error)

Removes a GS object. Bucket and Key values are trusted to be valid.

func (*Client) EnumerateObjects

func (gsa *Client) EnumerateObjects(bucket, after string, limit uint) ([]SizedObject, error)

List the objects in a GS bucket. If after is nonempty, listing will begin with lexically greater object names If limit is nonzero, the length of the list will be limited to that number.

func (*Client) GetObject

func (gsa *Client) GetObject(obj *Object) (io.ReadCloser, int64, error)

Fetch a GS object. Bucket and Key fields are trusted to be valid. Returns (object reader, object size, err). Reader must be closed.

func (*Client) PutObject

func (gsa *Client) PutObject(obj *Object, content io.ReadCloser) (shouldRetry bool, err error)

Upload a GS object. Bucket and Key are trusted to be valid. shouldRetry will be true if the put failed due to authorization, but credentials have been refreshed and another attempt is likely to succeed. In this case, content will have been consumed.

func (*Client) StatObject

func (gsa *Client) StatObject(obj *Object) (size int64, exists bool, err error)

Check for size / existence of a GS object. Bucket and Key fields are trusted to be valid. err signals io / authz errors, a nonexistant file is not an error.

type Object

type Object struct {
	Bucket string
	Key    string
}

func (Object) String

func (gso Object) String() string

type SizedObject

type SizedObject struct {
	Object
	Size int64
}

func (SizedObject) String

func (sgso SizedObject) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL