r2

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package r2 is the Cloudflare R2 storage provider for objects service

Index

Constants

View Source
const (
	// DefaultPresignedURLExpiry defines the default expiry time for presigned URLs
	DefaultPresignedURLExpiry = 15 * time.Minute
	// DefaultPartSize defines the default part size for multipart uploads (64MB)
	DefaultPartSize = 64 * 1024 * 1024
	// DefaultConcurrency defines the default concurrency for uploads
	DefaultConcurrency = 5
)

Variables

View Source
var (
	// ErrR2CredentialsRequired is returned when required R2 credentials are missing
	ErrR2CredentialsRequired = errors.New("missing required R2 credentials: bucket, account_id, access_key_id, secret_access_key")
	// ErrR2BucketRequired is returned when R2 bucket is not specified
	ErrR2BucketRequired = errors.New("R2 bucket is required")
	// ErrR2AccountIDRequired is returned when R2 account ID is not specified
	ErrR2AccountIDRequired = errors.New("R2 account ID is required")
	// ErrR2CredentialsMissing is returned when R2 access keys are missing
	ErrR2CredentialsMissing = errors.New("R2 access key ID and secret access key are required")
)

Functions

func NewR2ProviderFromCredentials

func NewR2ProviderFromCredentials(credentials storage.ProviderCredentials, options *storage.ProviderOptions) mo.Result[storagetypes.Provider]

NewR2ProviderFromCredentials creates an R2 provider using the supplied credentials and options

Types

type Builder

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

Builder creates R2 providers for the client pool

func NewR2Builder

func NewR2Builder() *Builder

NewR2Builder creates a new R2Builder

func (*Builder) Build

Build implements eddy.Builder

func (*Builder) ProviderType

func (b *Builder) ProviderType() string

ProviderType implements eddy.Builder

func (*Builder) WithOptions added in v0.39.2

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

WithOptions sets provider options for the builder

type Option added in v0.39.2

type Option func(*providerConfig)

Option configures the R2 provider during construction

func WithUsePathStyle added in v0.39.2

func WithUsePathStyle(use bool) Option

WithUsePathStyle configures the R2 client to use path-style addressing

type Provider

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

Provider implements the storagetypes.Provider interface for Cloudflare R2

func NewR2Provider

func NewR2Provider(options *storage.ProviderOptions, opts ...Option) (*Provider, error)

NewR2Provider creates a new R2 provider instance

func (*Provider) Close

func (p *Provider) Close() error

Close cleans up resources

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 checks if an object exists in R2

func (*Provider) GetPresignedURL

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

GetPresignedURL implements storagetypes.Provider

func (*Provider) GetScheme

func (p *Provider) GetScheme() *string

GetScheme returns the URI scheme for R2

func (*Provider) ListBuckets

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

ListBuckets lists the buckets in the current account.

func (*Provider) ProviderType

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

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