storage

package
v0.0.0-...-a5a65f0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2017 License: Apache-2.0 Imports: 18 Imported by: 1

Documentation

Overview

Package storage implements a generic Azure storage client, not specific to Camlistore.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidContainer

func IsValidContainer(container string) bool

IsValidContainer reports whether container is a valid container name, per Microsoft's naming restrictions.

See http://msdn.microsoft.com/en-us/library/azure/dd135715.aspx

Types

type Auth

type Auth struct {
	Account   string
	AccessKey []byte
}

Auth contains the credentials needed to connect to Azure storage

func (*Auth) SignRequest

func (a *Auth) SignRequest(req *http.Request)

SignRequest takes an existing *http.Request and signs it with the credentials in Auth. If no date header is set, SignRequest will set the date header to the current UTC time.

type Blob

type Blob struct {
	Name       string
	Properties BlobProperties
}

Blob holds the name and properties of a blob when returned with a list-operation

type BlobProperties

type BlobProperties struct {
	ContentLength int `xml:"Content-Length"`
}

BlobProperties holds some information about the blobs. There are many more fields than just the one below, see: http://msdn.microsoft.com/en-us/library/azure/dd135734.aspx

type Client

type Client struct {
	*Auth
	Transport http.RoundTripper // or nil for the default

	// Hostname is the hostname to use in the requests.
	// By default its <account>.blob.core.windows.net.
	Hostname string
}

Client is an Azure storage client.

func (*Client) Containers

func (c *Client) Containers() ([]*Container, error)

Containers list the containers active under the current account.

func (*Client) Delete

func (c *Client) Delete(container, key string) error

Delete deletes a blob from the specified container. It may take a few moments before the blob is actually deleted by Azure.

func (*Client) Get

func (c *Client) Get(container, key string) (body io.ReadCloser, size int64, err error)

Get retrieves a blob from Azure or returns os.ErrNotExist if not found

func (*Client) GetPartial

func (c *Client) GetPartial(container, key string, offset, length int64) (rc io.ReadCloser, err error)

GetPartial fetches part of the blob in container. If length is negative, the rest of the object is returned. The caller must close rc.

func (*Client) ListBlobs

func (c *Client) ListBlobs(container string, maxResults int) (blobs []*Blob, err error)

ListBlobs returns 0 to maxKeys (inclusive) items from the provided container. If the length of the returned items is equal to maxKeys, there is no indication whether or not the returned list is truncated.

func (*Client) PutObject

func (c *Client) PutObject(key, container string, md5 hash.Hash, size int64, body io.Reader) error

PutObject puts a blob to the specified container on Azure

func (*Client) Stat

func (c *Client) Stat(key, container string) (size int64, reterr error)

Stat Stats a blob in Azure. It returns 0, os.ErrNotExist if not found on Azure, otherwise reterr is real.

type Container

type Container struct {
	Name string
}

Container is the result of an enumeration of containers TODO(gv): There are come more properties being exposed by Azure that we don't need right now

type Error

type Error struct {
	Op     string
	Code   int         // HTTP status code
	Body   []byte      // response body
	Header http.Header // response headers

	AzureError XMLError
}

Error is the type returned by some API operations.

func (*Error) Error

func (e *Error) Error() string

Error returns a formatted error message

type XMLError

type XMLError struct {
	Code                      string
	Message                   string
	AuthenticationErrorDetail string
}

XMLError is the Error response from Azure.

Jump to

Keyboard shortcuts

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