r2

package
v2.18.2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 20 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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

WithOptions sets provider options for the builder

type Option

type Option func(*providerConfig)

Option configures the R2 provider during construction

func WithUsePathStyle

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) Copy

func (p *Provider) Copy(ctx context.Context, file *storagetypes.File, opts *storage.CopyOptions) error

Copy implements storage.Copier through a server-side object copy

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) ListObjects

func (p *Provider) ListObjects(ctx context.Context, prefix string, limit int) ([]string, error)

ListObjects returns the object keys under prefix, at most limit when limit is positive

func (*Provider) Open

func (p *Provider) Open(ctx context.Context, file *storagetypes.File) (io.ReadCloser, error)

Open implements storage.Opener by streaming the object body

func (*Provider) ProviderType

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

func (*Provider) Stat

Stat implements storage.Statter through a head request

func (*Provider) Touch

func (p *Provider) Touch(ctx context.Context, file *storagetypes.File) error

Touch implements storage.Toucher by requesting the first byte of the object and discarding it

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