Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloudConsoleObjectDetailURL ¶ added in v1.0.8
CloudConsoleObjectDetailURL returns a URL displaying an object detail view in the Google cloud console. See https://cloud.google.com/storage/docs/request-endpoints#console Returns https://console.cloud.google.com/storage/browser/_details/<BUCKET_NAME>/<OBJECT_NAME>
func CloudConsoleObjectListURL ¶ added in v1.0.8
CloudConsoleObjectListURL returns a URL displaying a list of objects under a given path prefix in the Google cloud console. See https://cloud.google.com/storage/docs/request-endpoints#console Returns https://console.cloud.google.com/storage/browser/<BUCKET_NAME>/<PATH_PREFIX>
Types ¶
type Bucket ¶
type Bucket interface { // Name returns the name of the bucket Name() string // Close closes gcs client associated with this bucket Close() error // Exists returns true if the object exists, false otherwise Exists(objectName string) (bool, error) // Upload uploads a local file to the bucket Upload(localPath string, objectName string, attrs ...object.AttrSetter) error // Download downloads an object in the bucket to a local file Download(objectName string, localPath string) error // Read reads object contents Read(objectName string) ([]byte, error) // Write replaces object contents with given content Write(objectName string, content []byte, attrs ...object.AttrSetter) error // WriteFromStream replaces object contents with content read from reader. // **WARNING** WriteFromStream will block until the reader's Read() method returns an EOF error. // The caller is responsible for closing whatever io source the reader is reading from // (for example a pipe). WriteFromStream(objectName string, reader io.Reader, attrs ...object.AttrSetter) error // Writer returns a WriteCloser for the given object path. // **WARNING** The caller is responsible for closing the writer! Writer(objectName string) io.WriteCloser // Delete deletes the object from the bucket Delete(objectName string) error // Attrs returns the attributes of an object (eg. creation time, cache control) Attrs(objectName string) (*storage.ObjectAttrs, error) // Update updates the attributes of an object (eg. cache control) Update(objectName string, attrs ...object.AttrSetter) error // NewLocker returns a Locker instance for the given object NewLocker(objectName string, maxWait time.Duration, options ...LockerOption) Locker }
Bucket offers a simple interface for operations on GCS buckets
type BucketOption ¶
type BucketOption func(options *BucketOptions)
func WithClientOptions ¶
func WithClientOptions(options ...option.ClientOption) BucketOption
type BucketOptions ¶
type BucketOptions struct { // Prefix is an optionally prefix to add to all object names in the bucket. Eg. // For bucket called "my-bucket" with a prefix of "my-prefix-", // bucket.Read("foo") will read the object "gs://my-bucket/my-prefix-foo" Prefix string // ClientOptions options to pass to storage client ClientOptions []option.ClientOption // Context use a custom context instead of context.Background Context context.Context }
BucketOptions optional configuration for a Bucket
type Locker ¶
type Locker interface { // ObjectName returns the name of the object associated with this lock ObjectName() string // Lock waits to acquire the lock, timing out after maxTime. It returns a lock id / object generation number // that must be passed in to Unlock Lock() (int64, error) // Unlock releases the lock. Unlock(lockId int64) error }
Locker is distributed locking mechanism implemented over GCS. Every Locker is associated with an object in a GCS bucket.
type LockerOption ¶
LockerOption used for configuring Locker options