objectstorage

package
v0.0.0-...-98cd694 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Unlicense Imports: 21 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 = errors.New("nil config provided")
)
View Source
var (
	// Providers are what we provide to the dependency injection framework.
	Providers = wire.NewSet(
		NewUploadManager,
	)
)

Functions

This section is empty.

Types

type Config

type Config struct {
	FilesystemConfig  *FilesystemConfig `json:"filesystem,omitempty"        toml:"filesystem,omitempty"`
	S3Config          *S3Config         `json:"s3,omitempty"                toml:"s3,omitempty"`
	GCPConfig         *GCPConfig        `json:"gcpConfig,omitempty"         toml:"gcp_config,omitempty"`
	BucketPrefix      string            `json:"bucketPrefix,omitempty"      toml:"bucket_prefix,omitempty"`
	BucketName        string            `json:"bucketName,omitempty"        toml:"bucket_name,omitempty"`
	UploadFilenameKey string            `json:"uploadFilenameKey,omitempty" toml:"upload_filename_key,omitempty"`
	Provider          string            `json:"provider,omitempty"          toml:"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 `json:"rootDirectory" toml:"root_directory,omitempty"`
	// 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 `json:"bucketName" toml:"bucket_name,omitempty"`
	// 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.

func (*MockUploader) ServeFiles

func (m *MockUploader) ServeFiles(res http.ResponseWriter, req *http.Request)

ServeFiles is a mock function.

type S3Config

type S3Config struct {
	BucketName string `json:"bucketName" toml:"bucket_name,omitempty"`
	// 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, routeParamManager routing.RouteParamManager) (*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.

func (*Uploader) ServeFiles

func (u *Uploader) ServeFiles(res http.ResponseWriter, req *http.Request)

ServeFiles saves a file to the blob.

Jump to

Keyboard shortcuts

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