b2

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*b2Options)

Option configures a B2 store.

func WithClient

func WithClient(client *b2.Client) Option

WithClient provides a pre-configured B2 client, skipping internal client creation. When set, WithCredentials is ignored.

func WithCredentials

func WithCredentials(keyID, appKey string) Option

WithCredentials sets the Backblaze application key ID and key used to authenticate. Ignored when WithClient is provided.

func WithPrefix

func WithPrefix(prefix string) Option

WithPrefix sets a key prefix prepended to every object key. Use this to isolate multiple repositories within a single bucket (e.g. "prod/" and "staging/").

type Store

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

Store implements store.ObjectStore for Backblaze B2.

func New

func New(bucketName string, opts ...Option) (*Store, error)

New creates a Store for the given bucket. Either WithCredentials or WithClient must be provided.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, key string) error

func (*Store) DeletePrefix

func (s *Store) DeletePrefix(ctx context.Context, prefix string) error

DeletePrefix deletes all objects under the given prefix.

func (*Store) Exists

func (s *Store) Exists(ctx context.Context, key string) (bool, error)

func (*Store) Flush

func (s *Store) Flush(ctx context.Context) error

func (*Store) Get

func (s *Store) Get(ctx context.Context, key string) ([]byte, error)

func (*Store) GetRange

func (s *Store) GetRange(ctx context.Context, key string, offset, length int64) ([]byte, error)

GetRange implements RangeGetter using a B2 ranged download, so a caller reading a packfile footer transfers a few hundred bytes rather than the whole object.

func (*Store) List

func (s *Store) List(ctx context.Context, prefix string) ([]string, error)

func (*Store) NewWriter

func (s *Store) NewWriter(ctx context.Context, key string) io.WriteCloser

NewWriter returns a streaming writer to the given key in B2. The caller must Close the writer to finalize the upload.

func (*Store) Put

func (s *Store) Put(ctx context.Context, key string, data []byte) error

func (*Store) SignedURL

func (s *Store) SignedURL(ctx context.Context, key string, validFor time.Duration) (string, error)

SignedURL returns a time-limited download URL for the given key.

func (*Store) Size

func (s *Store) Size(ctx context.Context, key string) (int64, error)

func (*Store) TotalSize

func (s *Store) TotalSize(ctx context.Context) (int64, error)

Jump to

Keyboard shortcuts

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