Documentation
¶
Overview ¶
Package gcsdriver provides a Google Cloud Storage driver for Trove.
The GCS driver stores objects in Google Cloud Storage. It implements the core driver.Driver interface plus MultipartDriver, PresignDriver, and RangeDriver capability interfaces.
DSN format:
gcs://PROJECT_ID/BUCKET gcs://PROJECT_ID/BUCKET?credentials=/path/to/key.json&endpoint=http://localhost:4443
Usage:
drv := gcsdriver.New() drv.Open(ctx, "gcs://my-project/my-bucket") t, err := trove.Open(drv)
Index ¶
- type GCSDriver
- func (d *GCSDriver) AbortMultipart(ctx context.Context, bucket, key, uploadID string) error
- func (d *GCSDriver) Client() *storage.Client
- func (d *GCSDriver) Close(_ context.Context) error
- func (d *GCSDriver) CompleteMultipart(ctx context.Context, bucket, key, uploadID string, parts []driver.PartInfo) (*driver.ObjectInfo, error)
- func (d *GCSDriver) Copy(ctx context.Context, srcBucket, srcKey, dstBucket, dstKey string, ...) (*driver.ObjectInfo, error)
- func (d *GCSDriver) CreateBucket(ctx context.Context, name string, _ ...driver.BucketOption) error
- func (d *GCSDriver) Delete(ctx context.Context, bucket, key string, _ ...driver.DeleteOption) error
- func (d *GCSDriver) DeleteBucket(ctx context.Context, name string) error
- func (d *GCSDriver) Get(ctx context.Context, bucket, key string, _ ...driver.GetOption) (*driver.ObjectReader, error)
- func (d *GCSDriver) GetRange(ctx context.Context, bucket, key string, offset, length int64) (*driver.ObjectReader, error)
- func (d *GCSDriver) Head(ctx context.Context, bucket, key string) (*driver.ObjectInfo, error)
- func (d *GCSDriver) InitiateMultipart(_ context.Context, bucket, key string, _ ...driver.PutOption) (string, error)
- func (d *GCSDriver) List(ctx context.Context, bucket string, opts ...driver.ListOption) (*driver.ObjectIterator, error)
- func (d *GCSDriver) ListBuckets(ctx context.Context) ([]driver.BucketInfo, error)
- func (d *GCSDriver) Name() string
- func (d *GCSDriver) Open(ctx context.Context, dsn string, opts ...driver.Option) error
- func (d *GCSDriver) Ping(ctx context.Context) error
- func (d *GCSDriver) PresignGet(_ context.Context, bucket, key string, expires time.Duration) (string, error)
- func (d *GCSDriver) PresignPut(_ context.Context, bucket, key string, expires time.Duration) (string, error)
- func (d *GCSDriver) Put(ctx context.Context, bucket, key string, r io.Reader, opts ...driver.PutOption) (*driver.ObjectInfo, error)
- func (d *GCSDriver) UploadPart(ctx context.Context, bucket, key, uploadID string, partNum int, r io.Reader) (*driver.PartInfo, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GCSDriver ¶
type GCSDriver struct {
// contains filtered or unexported fields
}
GCSDriver implements driver.Driver for Google Cloud Storage.
func (*GCSDriver) AbortMultipart ¶
AbortMultipart cancels a multipart upload and cleans up temporary objects.
func (*GCSDriver) CompleteMultipart ¶
func (d *GCSDriver) CompleteMultipart(ctx context.Context, bucket, key, uploadID string, parts []driver.PartInfo) (*driver.ObjectInfo, error)
CompleteMultipart composes all part objects into the final object and cleans up.
func (*GCSDriver) Copy ¶
func (d *GCSDriver) Copy(ctx context.Context, srcBucket, srcKey, dstBucket, dstKey string, _ ...driver.CopyOption) (*driver.ObjectInfo, error)
Copy copies an object within or across buckets.
func (*GCSDriver) CreateBucket ¶
CreateBucket creates a new GCS bucket.
func (*GCSDriver) DeleteBucket ¶
DeleteBucket removes a GCS bucket.
func (*GCSDriver) Get ¶
func (d *GCSDriver) Get(ctx context.Context, bucket, key string, _ ...driver.GetOption) (*driver.ObjectReader, error)
Get retrieves an object from GCS.
func (*GCSDriver) GetRange ¶
func (d *GCSDriver) GetRange(ctx context.Context, bucket, key string, offset, length int64) (*driver.ObjectReader, error)
GetRange retrieves a byte range of an object. The offset is the starting byte position and length is the number of bytes to read. A length of -1 reads from offset to end.
func (*GCSDriver) InitiateMultipart ¶
func (d *GCSDriver) InitiateMultipart(_ context.Context, bucket, key string, _ ...driver.PutOption) (string, error)
InitiateMultipart starts a multipart upload. GCS uses a compose pattern: parts are uploaded as temporary objects and composed into the final object.
func (*GCSDriver) List ¶
func (d *GCSDriver) List(ctx context.Context, bucket string, opts ...driver.ListOption) (*driver.ObjectIterator, error)
List returns objects matching the given options.
func (*GCSDriver) ListBuckets ¶
ListBuckets returns all accessible buckets.
func (*GCSDriver) PresignGet ¶
func (d *GCSDriver) PresignGet(_ context.Context, bucket, key string, expires time.Duration) (string, error)
PresignGet generates a pre-signed URL for downloading an object.
func (*GCSDriver) PresignPut ¶
func (d *GCSDriver) PresignPut(_ context.Context, bucket, key string, expires time.Duration) (string, error)
PresignPut generates a pre-signed URL for uploading an object.