googlestorage

package
v0.0.0-...-acef7dd Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2014 License: Apache-2.0 Imports: 10 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 gsinit' to help obtain the auth config object.

Documentation

Overview

Package googlestorage implements a generic Google Storage API client. It does not include any Camlistore-specific logic.

Index

Constants

View Source
const (
	Scope       = "https://www.googleapis.com/auth/devstorage.read_write"
	AuthURL     = "https://accounts.google.com/o/oauth2/auth"
	TokenURL    = "https://accounts.google.com/o/oauth2/token"
	RedirectURL = "urn:ietf:wg:oauth:2.0:oob"
)

Variables

This section is empty.

Functions

func MakeOauthTransport

func MakeOauthTransport(clientId string, clientSecret string, refreshToken string) *oauth.Transport

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 int) ([]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
y or Y : Canonical URL