stow: gomodules.xyz/stow/google Index | Files

package google

import "gomodules.xyz/stow/google"

Package google provides an abstraction of Google Cloud Storage. In this package, a Google Cloud Storage Bucket is represented by a Stow Container and a Google Cloud Storage Object is represented by a Stow Item. Note that directories may exist within a Bucket.

Usage and Credentials

A path to the JSON file representing configuration information for the service account is needed, as well as the Project ID that it is tied to.

stow.Dial requires both a string value of the particular Stow Location Kind ("google") and a stow.Config instance. The stow.Config instance requires two entries with the specific key value attributes:

- a key of google.ConfigJSON with a value of the path of the JSON configuration file - a key of google.ConfigProjectID with a value of the Project ID

Location

There are google.location methods which allow the retrieval of a Google Cloud Storage Object (Container or Containers). An Object can also be retrieved based on the its URL (ItemByURL).

Additional google.location methods provide capabilities to create and remove Google Cloud Storage Buckets (CreateContainer or RemoveContainer).

Container

Methods of stow.container allow the retrieval of a Google Bucket's:

- name(ID or Name) - object or complete list of objects (Item or Items, respectively)

Additional methods of google.container allow Stow to:

- remove an Object (RemoveItem) - update or create an Object (Put)

Item

Methods of google.Item allow the retrieval of a Google Cloud Storage Object's: - name (ID or name) - URL - size in bytes - Object specific metadata (information stored within the Google Cloud Service) - last modified date - Etag - content

Index

Package Files

config.go container.go doc.go item.go location.go

Constants

const (
    // The service account json blob
    ConfigJSON      = "json"
    ConfigProjectId = "project_id"
    ConfigScopes    = "scopes"
)
const Kind = "google"

Kind represents the name of the location/storage type.

type Container Uses

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

func (*Container) Browse Uses

func (c *Container) Browse(prefix string, delimiter string, cursor string, count int) (*stow.ItemPage, error)

func (*Container) Bucket Uses

func (c *Container) Bucket() (*storage.Bucket, error)

func (*Container) HasWriteAccess Uses

func (c *Container) HasWriteAccess() error

func (*Container) ID Uses

func (c *Container) ID() string

ID returns a string value which represents the name of the container.

func (*Container) Item Uses

func (c *Container) Item(id string) (stow.Item, error)

Item returns a stow.Item instance of a container based on the name of the container

func (*Container) Items Uses

func (c *Container) Items(prefix, cursor string, count int) ([]stow.Item, string, error)

Items retrieves a list of items that are prepended with the prefix argument. The 'cursor' variable facilitates pagination.

func (*Container) Name Uses

func (c *Container) Name() string

Name returns a string value which represents the name of the container.

func (*Container) Put Uses

func (c *Container) Put(name string, r io.Reader, size int64, metadata map[string]interface{}) (stow.Item, error)

Put sends a request to upload content to the container. The arguments received are the name of the item, a reader representing the content, and the size of the file.

func (*Container) RemoveItem Uses

func (c *Container) RemoveItem(id string) error

type Item Uses

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

func (*Item) ETag Uses

func (i *Item) ETag() (string, error)

ETag returns the ETag value

func (*Item) ID Uses

func (i *Item) ID() string

ID returns a string value that represents the name of a file.

func (*Item) LastMod Uses

func (i *Item) LastMod() (time.Time, error)

LastMod returns the last modified date of the item.

func (*Item) Metadata Uses

func (i *Item) Metadata() (map[string]interface{}, error)

Metadata returns a nil map and no error. TODO: Implement this.

func (*Item) Name Uses

func (i *Item) Name() string

Name returns a string value that represents the name of the file.

func (*Item) Open Uses

func (i *Item) Open() (io.ReadCloser, error)

Open returns an io.ReadCloser to the object. Useful for downloading/streaming the object.

func (*Item) Size Uses

func (i *Item) Size() (int64, error)

Size returns the size of an item in bytes.

func (*Item) StorageObject Uses

func (i *Item) StorageObject() *storage.Object

Object returns the Google Storage Object

func (*Item) URL Uses

func (i *Item) URL() *url.URL

URL returns a url which follows the predefined format

type Location Uses

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

A Location contains a client + the configurations used to create the client.

func (*Location) Close Uses

func (l *Location) Close() error

Close simply satisfies the Location interface. There's nothing that needs to be done in order to satisfy the interface.

func (*Location) Container Uses

func (l *Location) Container(id string) (stow.Container, error)

Container retrieves a stow.Container based on its name which must be exact.

func (*Location) Containers Uses

func (l *Location) Containers(prefix string, cursor string, count int) ([]stow.Container, string, error)

Containers returns a slice of the Container interface, a cursor, and an error.

func (*Location) CreateContainer Uses

func (l *Location) CreateContainer(containerName string) (stow.Container, error)

CreateContainer creates a new container, in this case a bucket.

func (*Location) ItemByURL Uses

func (l *Location) ItemByURL(url *url.URL) (stow.Item, error)

ItemByURL retrieves a stow.Item by parsing the URL, in this case an item is an object.

func (*Location) RemoveContainer Uses

func (l *Location) RemoveContainer(id string) error

RemoveContainer removes a container simply by name.

func (*Location) Service Uses

func (l *Location) Service() *storage.Service

Package google imports 12 packages (graph) and is imported by 7 packages. Updated 2019-08-13. Refresh now. Tools for package owners.