gcsx

package
v2.5.0-RC2+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2018 License: Apache-2.0, BSD-3-Clause, MIT Imports: 11 Imported by: 0

Documentation

Overview

Package gcsx contains utilities for working with Google Cloud Storage (GCS).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BucketExists

func BucketExists(client *storage.Service, bucket string) (bool, error)

BucketExists returns true iff the given bucket exists.

func CreateBucket

func CreateBucket(client *storage.Service, project, bucket string) error

CreateBucket creates a bucket in GCS.

func MakeObject

func MakeObject(bucket, path string) string

MakeObject creates a object location from bucket and path. For example, MakeObject("foo", "bar/baz") returns "gs://foo/bar/baz". The bucket must be non-empty.

func NewClient

func NewClient(ctx context.Context, scope string) (*storage.Service, error)

NewClient creates a new GCS client with default application credentials.

func NewUnauthenticatedClient

func NewUnauthenticatedClient(ctx context.Context) (*storage.Service, error)

NewUnauthenticatedClient creates a new GCS client without authentication.

func ParseObject

func ParseObject(object string) (bucket, path string, err error)

ParseObject deconstructs a GCS object name into (bucket, name).

func ReadObject

func ReadObject(client *storage.Service, bucket, object string) ([]byte, error)

ReadObject reads the content of the given object in full.

func Upload

func Upload(client *storage.Service, project, bucket, object string, r io.Reader) (string, error)

Upload writes the given content to GCS. If the specified bucket does not exist, it is created first. Returns the full path of the object.

func WriteObject

func WriteObject(client *storage.Service, bucket, object string, r io.Reader) error

WriteObject writes the given content to the specified object. If the object already exist, it is overwritten.

Types

This section is empty.

Jump to

Keyboard shortcuts

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