googlestorage

package
v0.0.0-...-d6cb8d1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2015 License: Apache-2.0 Imports: 19 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.  

Server configuration
=====================

High-level server config is formatted like:

	"googlecloudstorage": "clientId:clientSecret:refreshToken:bucketName"


Testing
========

googlestorage_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 '~/.config/camlistore/gstestconfig.json'.  The 
    file should look something like this:

	{
		"gsconf": {
			"auth": {
				"client_id": "your client id",
				"client_secret": "your client secret",
				"refresh_token": "a refresh token"
			},
			"bucket": "bucketName"
		}
	}


	You can use 'camtool googinit' to help obtain the auth config object.

Documentation

Overview

Package googlestorage is simple Google Cloud Storage client.

It does not include any Camlistore-specific logic.

Index

Constants

View Source
const (

	// Scope is the OAuth2 scope used for Google Cloud Storage.
	Scope = "https://www.googleapis.com/auth/devstorage.read_write"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

A Client provides access to Google Cloud Storage.

func NewClient

func NewClient(oauthClient *http.Client) *Client

func NewServiceClient

func NewServiceClient() (*Client, error)

NewServiceClient returns a Client for use when running on Google Compute Engine. This client can access buckets owned by the same project ID as the VM.

func (*Client) BucketInfo

func (c *Client) BucketInfo(bucket string) (*api.Bucket, error)

BucketInfo returns information about a bucket.

func (*Client) DeleteObject

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

DeleteObject removes an object.

func (*Client) EnumerateObjects

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

EnumerateObjects lists the objects in a bucket. If after is non-empty, listing will begin with lexically greater object names. If limit is non-zero, the length of the list will be limited to that number.

func (*Client) GetObject

func (c *Client) GetObject(obj *Object) (rc io.ReadCloser, size int64, err error)

GetObject fetches a Google Cloud Storage object. The caller must close rc.

func (*Client) GetPartialObject

func (c *Client) GetPartialObject(obj Object, offset, length int64) (rc io.ReadCloser, err error)

GetPartialObject fetches part of a Google Cloud Storage object. If length is negative, the rest of the object is returned. The caller must close rc.

func (*Client) PutObject

func (gsa *Client) PutObject(obj *Object, content io.Reader) error

PutObject uploads a Google Cloud Storage object. 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)

StatObject checks for the size & existence of a Google Cloud Storage object. Non-existence of a file is not an error.

type Object

type Object struct {
	Bucket string
	Key    string
}

An Object holds the name of an object (its bucket and key) within Google Cloud Storage.

func (*Object) String

func (o *Object) String() string

type SizedObject

type SizedObject struct {
	Object
	Size int64
}

A SizedObject holds the bucket, key, and size of an object.

func (SizedObject) String

func (so SizedObject) String() string

Jump to

Keyboard shortcuts

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