storage

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2017 License: Apache-2.0 Imports: 18 Imported by: 3

Documentation

Overview

storage provides a high level interface for Google Cloud Storage

Index

Examples

Constants

View Source
const MaxConcurrentRequests = 12

Arbitrary limit on the number of concurrent remote API requests.

Variables

View Source
var (
	UnknownScheme = errors.New("storage: URL missing gs:// scheme")
	UnknownBucket = errors.New("storage: URL missing bucket name")
)

Functions

func FixPrefix

func FixPrefix(p string) string

FixPrefix ensures non-empty paths end in a slash but never start with one.

func NextPrefix

func NextPrefix(name string) string

NextPrefix chops off the final component of an object name or prefix.

Example
fmt.Println(NextPrefix("foo/bar/baz"))
fmt.Println(NextPrefix("foo/bar/"))
fmt.Println(NextPrefix("foo/bar"))
fmt.Println(NextPrefix("foo/"))
fmt.Println(NextPrefix("foo"))
fmt.Println(NextPrefix(""))
Output:

foo/bar/
foo/
foo/

func SortObjects

func SortObjects(objs []*storage.Object)

SortObjects orders Objects by Name using natural sorting.

func Sync

func Sync(ctx context.Context, src, dst *Bucket) error

Types

type Bucket

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

func NewBucket

func NewBucket(client *http.Client, bucketURL string) (*Bucket, error)

func (*Bucket) Copy

func (b *Bucket) Copy(ctx context.Context, src *storage.Object, dstName string) error

func (*Bucket) Delete

func (b *Bucket) Delete(ctx context.Context, objName string) error

func (*Bucket) Fetch

func (b *Bucket) Fetch(ctx context.Context) error

func (*Bucket) FetchPrefix

func (b *Bucket) FetchPrefix(ctx context.Context, prefix string, recursive bool) error

func (*Bucket) Len

func (b *Bucket) Len() int

func (*Bucket) Name

func (b *Bucket) Name() string

func (*Bucket) Object

func (b *Bucket) Object(objName string) *storage.Object

func (*Bucket) Objects

func (b *Bucket) Objects() []*storage.Object

func (*Bucket) Prefix

func (b *Bucket) Prefix() string

func (*Bucket) Prefixes

func (b *Bucket) Prefixes() []string

func (*Bucket) URL

func (b *Bucket) URL() *url.URL

func (*Bucket) Upload

func (b *Bucket) Upload(ctx context.Context, obj *storage.Object, media io.ReaderAt) error

func (*Bucket) WriteAlways

func (b *Bucket) WriteAlways(always bool)

func (*Bucket) WriteDryRun

func (b *Bucket) WriteDryRun(dryrun bool)

type Error

type Error struct {
	Op  string
	URL string
	Err error
}

func (*Error) Error

func (e *Error) Error() string

type Filter

type Filter func(*gs.Object) bool

Filter is a type of function that returns true if an object should be included in a given operation or false if it should be excluded/ignored.

type ObjectSlice

type ObjectSlice []*storage.Object

ObjectSlice provides sort.Interface for natural sorting Objects by Name.

func (ObjectSlice) Len

func (objs ObjectSlice) Len() int

func (ObjectSlice) Less

func (objs ObjectSlice) Less(i, j int) bool

func (ObjectSlice) Swap

func (objs ObjectSlice) Swap(i, j int)

type SyncJob

type SyncJob struct {
	Source      *Bucket
	Destination *Bucket
	// contains filtered or unexported fields
}

func (*SyncJob) Delete

func (sj *SyncJob) Delete(enable bool)

Delete toggles deletion of extra objects from Destination.

func (*SyncJob) DeleteFilter

func (sj *SyncJob) DeleteFilter(f Filter)

DeleteFilter selects which objects may be pruned from Destination.

func (*SyncJob) DestinationPrefix

func (sj *SyncJob) DestinationPrefix(p string)

DestinationPrefix overrides the Destination bucket's default prefix.

func (*SyncJob) Do

func (sj *SyncJob) Do(ctx context.Context) error

func (*SyncJob) Recursive

func (sj *SyncJob) Recursive(enable bool)

Recursive toggles copying subdirectories from Source (the default).

func (*SyncJob) SourceFilter

func (sj *SyncJob) SourceFilter(f Filter)

SourceFilter selects which objects to copy from Source.

func (*SyncJob) SourcePrefix

func (sj *SyncJob) SourcePrefix(p string)

SourcePrefix overrides the Source bucket's default prefix.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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