gcs

package
v0.0.0-...-86c6960 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: Apache-2.0, Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContextTimeout  = "GCS_CONTEXT_TIMEOUT"
	NormalizePrefix = "GCS_NORMALIZE_PREFIX"
	EncryptionKey   = "GCS_ENCRYPTION_KEY"
	MaxChunkSize    = "GCS_MAX_CHUNK_SIZE"
	MaxRetries      = "GCS_MAX_RETRIES"
)

Variables

View Source
var (
	// BaseRetryDelay defines the first delay for retry.
	BaseRetryDelay = 128 * time.Millisecond

	// SettingList provides a list of GCS folder settings.
	SettingList = []string{
		ContextTimeout,
		NormalizePrefix,
		EncryptionKey,
		MaxChunkSize,
		MaxRetries,
	}
)

Functions

func ConfigureFolder

func ConfigureFolder(prefix string, settings map[string]string) (storage.Folder, error)

func NewError

func NewError(err error, format string, args ...interface{}) storage.Error

func NewFolderError

func NewFolderError(err error, format string, args ...interface{}) storage.Error

Types

type Folder

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

Folder represents folder in GCP

func NewFolder

func NewFolder(bucket *gcs.BucketHandle, path string, contextTimeout int, normalizePrefix bool, encryptionKey []byte,
	options []UploaderOption) *Folder

func (*Folder) BuildObjectHandle

func (folder *Folder) BuildObjectHandle(path string) *gcs.ObjectHandle

BuildObjectHandle creates a new object handle.

func (*Folder) CopyObject

func (folder *Folder) CopyObject(srcPath string, dstPath string) error

func (*Folder) DeleteObjects

func (folder *Folder) DeleteObjects(objectRelativePaths []string) error

func (*Folder) Exists

func (folder *Folder) Exists(objectRelativePath string) (bool, error)

func (*Folder) GetPath

func (folder *Folder) GetPath() string

func (*Folder) GetSubFolder

func (folder *Folder) GetSubFolder(subFolderRelativePath string) storage.Folder

func (*Folder) ListFolder

func (folder *Folder) ListFolder() (objects []storage.Object, subFolders []storage.Folder, err error)

func (*Folder) PutObject

func (folder *Folder) PutObject(name string, content io.Reader) error

func (*Folder) ReadObject

func (folder *Folder) ReadObject(objectRelativePath string) (io.ReadCloser, error)

type Uploader

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

func NewUploader

func NewUploader(objHandle *storage.ObjectHandle, options ...UploaderOption) *Uploader

func (*Uploader) CleanUpChunks

func (u *Uploader) CleanUpChunks(ctx context.Context, tmpChunks []*storage.ObjectHandle)

CleanUpChunks removes temporary chunks.

func (*Uploader) ComposeObject

func (u *Uploader) ComposeObject(ctx context.Context, tmpChunks []*storage.ObjectHandle) error

ComposeObject composes an object from temporary chunks.

func (*Uploader) UploadChunk

func (u *Uploader) UploadChunk(ctx context.Context, chunk chunk) error

UploadChunk uploads ab object chunk to storage.

type UploaderOption

type UploaderOption func(*Uploader)

Jump to

Keyboard shortcuts

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