Help us shape the future of Go! Take the 2026 Go Developer Survey

gcs

package
v2.9.2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package gcs is the Google Cloud Storage provider for objects service

Index

Constants

View Source
const (
	// DefaultPresignedURLExpiry defines the default expiry time for signed URLs
	DefaultPresignedURLExpiry = 15 * time.Minute
	// ReadWriteScope is the OAuth scope granting object reads and writes in a bucket
	ReadWriteScope = "https://www.googleapis.com/auth/devstorage.read_write"
)

Variables

View Source
var (
	// ErrBucketRequired is returned when no GCS bucket is specified
	ErrBucketRequired = errors.New("gcs: bucket is required")
	// ErrProjectIDRequired is returned when listing buckets without a project id
	ErrProjectIDRequired = errors.New("gcs: project id is required")
	// ErrClientCreate is returned when the GCS client could not be created
	ErrClientCreate = errors.New("gcs: client creation failed")
	// ErrServiceAccountKeyInvalid is returned when a service account key JSON cannot be parsed
	ErrServiceAccountKeyInvalid = errors.New("gcs: service account key invalid")
)

Functions

This section is empty.

Types

type Builder

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

Builder creates GCS providers for the client pool

func NewBuilder

func NewBuilder() *Builder

NewBuilder creates a new Builder

func (*Builder) Build

Build implements eddy.Builder

func (*Builder) ProviderType

func (b *Builder) ProviderType() string

ProviderType implements eddy.Builder

func (*Builder) WithOptions

func (b *Builder) WithOptions(opts ...Option) *Builder

WithOptions sets provider options for the builder

type Option

type Option func(*providerConfig)

Option configures the GCS provider during construction

func WithClientOptions

func WithClientOptions(opts ...option.ClientOption) Option

WithClientOptions supplies Google API client options such as a credential token source; omitted, the client uses application default credentials

func WithServiceAccountKey

func WithServiceAccountKey(ctx context.Context, key []byte) (Option, error)

WithServiceAccountKey authenticates the client with a service account key JSON under ReadWriteScope

type Provider

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

Provider implements storagetypes.Provider against Google Cloud Storage

func NewProvider

func NewProvider(ctx context.Context, options *storage.ProviderOptions, opts ...Option) (*Provider, error)

NewProvider creates a GCS provider for the bucket in options, authenticating with application default credentials unless client options say otherwise

func (*Provider) Bucket

func (p *Provider) Bucket() string

Bucket returns the bucket the provider reads and writes by default

func (*Provider) Close

func (p *Provider) Close() error

Close implements storagetypes.Provider

func (*Provider) Copy

func (p *Provider) Copy(ctx context.Context, file *storagetypes.File, opts *storage.CopyOptions) error

Copy implements storage.Copier through a server-side object copy

func (*Provider) Delete

Delete implements storagetypes.Provider

func (*Provider) Download

Download implements storagetypes.Provider

func (*Provider) Exists

func (p *Provider) Exists(ctx context.Context, file *storagetypes.File) (bool, error)

Exists implements storagetypes.Provider

func (*Provider) GetPresignedURL

func (p *Provider) GetPresignedURL(_ context.Context, file *storagetypes.File, opts *storagetypes.PresignedURLOptions) (string, error)

GetPresignedURL implements storagetypes.Provider

func (*Provider) GetScheme

func (p *Provider) GetScheme() *string

GetScheme implements storagetypes.Provider

func (*Provider) ListBuckets

func (p *Provider) ListBuckets() ([]string, error)

ListBuckets implements storagetypes.Provider

func (*Provider) ListObjects

func (p *Provider) ListObjects(ctx context.Context, prefix string, limit int) ([]string, error)

ListObjects returns the object keys under prefix, at most limit when limit is positive

func (*Provider) ProviderType

func (p *Provider) ProviderType() storagetypes.ProviderType

ProviderType implements storagetypes.Provider

func (*Provider) Upload

Upload implements storagetypes.Provider

Jump to

Keyboard shortcuts

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