Documentation ¶
Overview ¶
storage provides a high level interface for Google Cloud Storage
Index ¶
- Constants
- Variables
- func FixPrefix(p string) string
- func NextPrefix(name string) string
- func SortObjects(objs []*storage.Object)
- func Sync(ctx context.Context, src, dst *Bucket) error
- type Bucket
- func (b *Bucket) Copy(ctx context.Context, src *storage.Object, dstName string) error
- func (b *Bucket) Delete(ctx context.Context, objName string) error
- func (b *Bucket) Fetch(ctx context.Context) error
- func (b *Bucket) FetchPrefix(ctx context.Context, prefix string, recursive bool) error
- func (b *Bucket) Len() int
- func (b *Bucket) Name() string
- func (b *Bucket) Object(objName string) *storage.Object
- func (b *Bucket) Objects() []*storage.Object
- func (b *Bucket) Prefix() string
- func (b *Bucket) Prefixes() []string
- func (b *Bucket) URL() *url.URL
- func (b *Bucket) Upload(ctx context.Context, obj *storage.Object, media io.ReadSeeker) error
- func (b *Bucket) WriteAlways(always bool)
- func (b *Bucket) WriteDryRun(dryrun bool)
- type Error
- type Filter
- type ObjectSlice
- type SyncJob
- func (sj *SyncJob) Delete(enable bool)
- func (sj *SyncJob) DeleteFilter(f Filter)
- func (sj *SyncJob) DestinationPrefix(p string)
- func (sj *SyncJob) Do(ctx context.Context) error
- func (sj *SyncJob) Recursive(enable bool)
- func (sj *SyncJob) SourceFilter(f Filter)
- func (sj *SyncJob) SourcePrefix(p string)
Examples ¶
Constants ¶
const MaxConcurrentRequests = 12
Arbitrary limit on the number of concurrent remote API requests.
Variables ¶
var ( UnknownScheme = errors.New("storage: URL missing gs:// scheme") UnknownBucket = errors.New("storage: URL missing bucket name") )
Functions ¶
func NextPrefix ¶
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.
Types ¶
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
func (*Bucket) FetchPrefix ¶
func (*Bucket) WriteAlways ¶
func (*Bucket) WriteDryRun ¶
type Filter ¶
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) DeleteFilter ¶
DeleteFilter selects which objects may be pruned from Destination.
func (*SyncJob) DestinationPrefix ¶
DestinationPrefix overrides the Destination bucket's default prefix.
func (*SyncJob) SourceFilter ¶
SourceFilter selects which objects to copy from Source.
func (*SyncJob) SourcePrefix ¶
SourcePrefix overrides the Source bucket's default prefix.