storage

package
v0.0.0-...-379680d Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2019 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

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

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(ctx context.Context) ([]*Container, error)

Containers list the containers active under the current account.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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