blob

package module
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: May 19, 2025 License: MIT Imports: 10 Imported by: 0

README

blob-go

Provides a common interface that blob storage providers should satisfy, as well as common implementations for Local Files and Google Cloud Storage.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fs added in v1.0.4

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

Implements the Storage interface for the local file system.

func NewFsStorage added in v1.0.5

func NewFsStorage(basePath string) *Fs

Returns a new Fs instance.

func (*Fs) Read added in v1.0.4

func (l *Fs) Read(ctx context.Context, key string) ([]byte, error)

Reads a blob from the local file system.

func (*Fs) Remove added in v1.0.4

func (l *Fs) Remove(ctx context.Context, key string) error

Removes a blob from the local file system.

func (*Fs) RemoveFolder added in v1.0.6

func (l *Fs) RemoveFolder(ctx context.Context, folder string) error

Removes a folder

func (*Fs) Write added in v1.0.4

func (l *Fs) Write(ctx context.Context, key string, data []byte) error

Writes a blob to the local file system.

func (*Fs) WriteIfMissing added in v1.0.4

func (l *Fs) WriteIfMissing(ctx context.Context, key string, data []byte) error

Writes a blob to the local file system if the key does not contain any data yet

type Gcs added in v1.0.4

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

Gcs implements Storage for Google Cloud Storage.

func NewGcsStorage added in v1.0.5

func NewGcsStorage(ctx context.Context, bucket string, prefix string) (*Gcs, error)

Returns a new Gcs blob storage instance.

func (*Gcs) Read added in v1.0.4

func (g *Gcs) Read(ctx context.Context, key string) ([]byte, error)

Reads a blob from Google Cloud Storage.

func (*Gcs) Remove added in v1.0.4

func (g *Gcs) Remove(ctx context.Context, key string) error

Remove removes a blob from Google Cloud Storage.

func (*Gcs) RemoveFolder added in v1.0.6

func (g *Gcs) RemoveFolder(ctx context.Context, folder string) error

Removes all objects at the specified folder (prefix)

func (*Gcs) Write added in v1.0.4

func (g *Gcs) Write(ctx context.Context, key string, data []byte) error

Writes a blob to Google Cloud Storage.

func (*Gcs) WriteIfMissing added in v1.0.4

func (g *Gcs) WriteIfMissing(ctx context.Context, key string, data []byte) error

Writes a blob to Google Cloud Storage if the key does not contain any data yet

type Storage added in v1.0.5

type Storage interface {
	// Reads a blob
	Read(ctx context.Context, key string) ([]byte, error)
	// Writes a blob
	Write(ctx context.Context, key string, data []byte) error
	// Writes a blob if the key does not contain any data yet
	WriteIfMissing(ctx context.Context, key string, data []byte) error
	// Removes a blob if it exists
	Remove(ctx context.Context, key string) error
	// Removes a folder and all children blobs
	RemoveFolder(ctx context.Context, folder string) error
}

A simplified interface for interacting with blob storage.

Jump to

Keyboard shortcuts

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