objectstorage

package
v2.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

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 (
	// 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")
)
View Source
var (
	// Providers are what we provide to the dependency injection framework.
	Providers = wire.NewSet(
		NewUploadManager,
		ProvideUploadManager,
	)
)

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 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"`
	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"`
	// 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 MockUploader

type MockUploader struct {
	mock.Mock
}

MockUploader is a mock uploads.UploadManager.

func (*MockUploader) ReadFile

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

ReadFile is a mock function.

func (*MockUploader) SaveFile

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

SaveFile is a mock function.

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, 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