gcloudstorage

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package gcloudstorage provides convenience wrapper over cloud.google.com/go/storage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option added in v1.0.8

type Option func(*Storage)

func WithChunkSize added in v1.0.2

func WithChunkSize(size int) Option

WithChunkSize limits the maximum chunk size used by storage.Writer

Note that retries are not supported for chunk size 0.

func WithTimeout added in v1.0.2

func WithTimeout(timeout time.Duration) Option

WithTimeout sets the timeout limit on inner contexts to prevent long requests from bloating goroutines scheduler.

type Storage

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

Storage is a storage wrapper struct exposing methods that are useful for the caller.

func NewBucket

func NewBucket(ctx context.Context, name string, opts ...Option) (*Storage, error)

func (*Storage) Attributes

func (s *Storage) Attributes(ctx context.Context, name string) (*storage.ObjectAttributes, error)

func (*Storage) Close

func (s *Storage) Close() error

Close closes the inner client

Note that inner client becomes useless after that.

func (*Storage) DeleteFile

func (s *Storage) DeleteFile(ctx context.Context, name string) error

DeleteFile removes file from bucket storage.

func (*Storage) DownloadFileBytes

func (s *Storage) DownloadFileBytes(ctx context.Context, name string) ([]byte, error)

DownloadFileBytes downloads the file using file name.

func (*Storage) DownloadFileReader

func (s *Storage) DownloadFileReader(ctx context.Context, name string) (io.ReadCloser, error)

DownloadFileReader creates full file download reader.

func (*Storage) DownloadRangeReader

func (s *Storage) DownloadRangeReader(
	ctx context.Context,
	name string,
	offset int64,
	length int64,
) (io.ReadCloser, error)

DownloadRangeReader creates range file download reader.

func (*Storage) Downloader

func (s *Storage) Downloader(ctx context.Context, name string, size int64) io.ReadSeeker

Downloader creates io.ReadSeeker.

Useful for serving files where full content download ahead of time is expensive (e.g. with [http.ServeContent]).

func (*Storage) UpdateFile

func (s *Storage) UpdateFile(
	ctx context.Context,
	name string,
	attrs storage.UpdateAttributes,
) error

UpdateFile updates object attributes.

func (*Storage) UploadFile

func (s *Storage) UploadFile(ctx context.Context, name string, r io.Reader) error

UploadFile uploads the file using file name and provided reader.

Jump to

Keyboard shortcuts

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