objectstorage

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BackblazeB2Provider indicates we'd like to use the Backblaze B2 adapter for blob.
	BackblazeB2Provider = "backblaze_b2"
)
View Source
const (
	// FilesystemProvider indicates we'd like to use the filesystem adapter for blob.
	FilesystemProvider = "filesystem"
)
View Source
const (
	// GCPCloudStorageProvider indicates we'd like to use the GCP adapter for blob objectstorage.
	GCPCloudStorageProvider = "gcp"
)
View Source
const (
	// MemoryProvider indicates we'd like to use the memory adapter for blob.
	MemoryProvider = "memory"
)
View Source
const (
	// R2Provider indicates we'd like to use the Cloudflare R2 adapter for blob.
	R2Provider = "r2"
)
View Source
const (
	// S3Provider indicates we'd like to use the s3 adapter for blob.
	S3Provider = "s3"
)

Variables

View Source
var (
	// ErrNilConfig denotes that the provided configuration is nil.
	ErrNilConfig = platformerrors.New("nil config provided")
)

Functions

func ProvideUploadManager

func ProvideUploadManager(u *Uploader) uploads.UploadManager

ProvideUploadManager transforms an *objectstorage.Uploader into an UploadManager.

func RegisterUploadManager

func RegisterUploadManager(i do.Injector)

RegisterUploadManager registers both *Uploader and uploads.UploadManager with the injector. Prerequisite: *Config must be registered (e.g. via uploadscfg.RegisterStorageConfig).

Types

type BackblazeB2Config

type BackblazeB2Config struct {
	ApplicationKeyID string `env:"APPLICATION_KEY_ID" json:"applicationKeyID"`
	ApplicationKey   string `env:"APPLICATION_KEY"    json:"applicationKey"`
	BucketName       string `env:"BUCKET_NAME"        json:"bucketName"`
	Region           string `env:"REGION"             json:"region"`
	// contains filtered or unexported fields
}

BackblazeB2Config configures a Backblaze B2-based objectstorage provider.

func (*BackblazeB2Config) ValidateWithContext

func (c *BackblazeB2Config) ValidateWithContext(ctx context.Context) error

ValidateWithContext validates the BackblazeB2Config.

type Config

type Config struct {
	FilesystemConfig  *FilesystemConfig         `env:"init"                envPrefix:"FILESYSTEM_"            json:"filesystem,omitempty"`
	S3Config          *S3Config                 `env:"init"                envPrefix:"S3_"                    json:"s3,omitempty"`
	GCP               *GCPConfig                `env:"init"                envPrefix:"GCP_"                   json:"gcpConfig,omitempty"`
	R2Config          *R2Config                 `env:"init"                envPrefix:"R2_"                    json:"r2,omitempty"`
	BackblazeB2Config *BackblazeB2Config        `env:"init"                envPrefix:"BACKBLAZE_B2_"          json:"backblazeB2,omitempty"`
	BucketPrefix      string                    `env:"BUCKET_PREFIX"       json:"bucketPrefix,omitempty"`
	BucketName        string                    `env:"BUCKET_NAME"         json:"bucketName,omitempty"`
	UploadFilenameKey string                    `env:"UPLOAD_FILENAME_KEY" json:"uploadFilenameKey,omitempty"`
	Provider          string                    `env:"PROVIDER"            json:"provider,omitempty"`
	CircuitBreaker    circuitbreakingcfg.Config `env:"init"                envPrefix:"CIRCUIT_BREAKING_"      json:"circuitBreakerConfig"`
	// contains filtered or unexported fields
}

Config configures our UploadManager.

func (*Config) ValidateWithContext

func (c *Config) ValidateWithContext(ctx context.Context) error

ValidateWithContext validates the Config.

type FilesystemConfig

type FilesystemConfig struct {
	RootDirectory string `env:"ROOT_DIRECTORY" json:"rootDirectory"`
	// contains filtered or unexported fields
}

FilesystemConfig configures a filesystem-based objectstorage provider.

func (*FilesystemConfig) ValidateWithContext

func (c *FilesystemConfig) ValidateWithContext(ctx context.Context) error

ValidateWithContext validates the FilesystemConfig.

type GCPConfig

type GCPConfig struct {
	BucketName string `env:"BUCKET_NAME" json:"bucketName"`
	// contains filtered or unexported fields
}

GCPConfig configures an GCP-based objectstorage provider.

func (*GCPConfig) ValidateWithContext

func (c *GCPConfig) ValidateWithContext(ctx context.Context) error

ValidateWithContext validates the GCPCloudStorageConfig.

type R2Config

type R2Config struct {
	AccountID       string `env:"ACCOUNT_ID"        json:"accountID"`
	BucketName      string `env:"BUCKET_NAME"       json:"bucketName"`
	AccessKeyID     string `env:"ACCESS_KEY_ID"     json:"accessKeyID"`
	SecretAccessKey string `env:"SECRET_ACCESS_KEY" json:"secretAccessKey"`
	// contains filtered or unexported fields
}

R2Config configures a Cloudflare R2-based objectstorage provider.

func (*R2Config) ValidateWithContext

func (c *R2Config) ValidateWithContext(ctx context.Context) error

ValidateWithContext validates the R2Config.

type S3Config

type S3Config struct {
	BucketName string `env:"BUCKET_NAME" json:"bucketName"`
	// contains filtered or unexported fields
}

S3Config configures an S3-based objectstorage provider.

func (*S3Config) ValidateWithContext

func (c *S3Config) ValidateWithContext(ctx context.Context) error

ValidateWithContext validates the S3Config.

type Uploader

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

Uploader implements our UploadManager struct.

func NewUploadManager

func NewUploadManager(ctx context.Context, logger logging.Logger, tracerProvider tracing.TracerProvider, metricsProvider metrics.Provider, cfg *Config) (*Uploader, error)

NewUploadManager provides a new uploads.UploadManager.

func (*Uploader) ReadFile

func (u *Uploader) ReadFile(ctx context.Context, path string) ([]byte, error)

ReadFile reads a file from the blob.

func (*Uploader) SaveFile

func (u *Uploader) SaveFile(ctx context.Context, path string, content []byte) error

SaveFile saves a file to the blob.

Jump to

Keyboard shortcuts

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