storage

package
v0.0.0-...-21c6822 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GCSStorage

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

GCSStorage implements the Storage interface for Google Cloud Storage.

func NewGCSStorage

func NewGCSStorage(ctx context.Context, cfg GCSStorageConfig) (*GCSStorage, error)

NewGCSStorage creates a new GCSStorage instance.

func (*GCSStorage) Delete

func (g *GCSStorage) Delete(ctx context.Context, bucketName, objectName string) error

Delete removes a file from GCS.

func (*GCSStorage) Download

func (g *GCSStorage) Download(ctx context.Context, bucketName, objectName string) (io.ReadCloser, error)

Download retrieves a file from GCS.

func (*GCSStorage) GetSignedURL

func (g *GCSStorage) GetSignedURL(ctx context.Context, bucketName, objectName string, method string, durationMinutes int) (string, error)

GetSignedURL generates a signed URL for GCS.

func (*GCSStorage) Upload

func (g *GCSStorage) Upload(ctx context.Context, bucketName, objectName string, file io.Reader) (string, error)

Upload saves a file to GCS.

type GCSStorageConfig

type GCSStorageConfig struct {
	ProjectID       string `mapstructure:"project_id"`
	Bucket          string `mapstructure:"bucket"`
	CredentialsFile string `mapstructure:"credentials_file"`
}

GCSStorageConfig holds configuration for GCS storage.

type LocalStorage

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

LocalStorage implements the Storage interface for local file system.

func NewLocalStorage

func NewLocalStorage(cfg LocalStorageConfig) (*LocalStorage, error)

NewLocalStorage creates a new LocalStorage instance.

func (*LocalStorage) Delete

func (l *LocalStorage) Delete(ctx context.Context, bucketName, objectName string) error

Delete removes a file from the local file system.

func (*LocalStorage) Download

func (l *LocalStorage) Download(ctx context.Context, bucketName, objectName string) (io.ReadCloser, error)

Download retrieves a file from the local file system.

func (*LocalStorage) GetSignedURL

func (l *LocalStorage) GetSignedURL(ctx context.Context, bucketName, objectName string, method string, durationMinutes int) (string, error)

GetSignedURL generates a signed URL for local storage. This is a placeholder as local storage doesn't inherently support signed URLs.

func (*LocalStorage) Upload

func (l *LocalStorage) Upload(ctx context.Context, bucketName, objectName string, file io.Reader) (string, error)

Upload saves a file to the local file system.

type LocalStorageConfig

type LocalStorageConfig struct {
	BasePath string `mapstructure:"base_path"`
}

LocalStorageConfig holds configuration for local storage.

type S3Storage

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

S3Storage implements the Storage interface for AWS S3.

func NewS3Storage

func NewS3Storage(cfg S3StorageConfig) (*S3Storage, error)

NewS3Storage creates a new S3Storage instance.

func (*S3Storage) Delete

func (s *S3Storage) Delete(ctx context.Context, bucketName, objectName string) error

Delete removes a file from S3.

func (*S3Storage) Download

func (s *S3Storage) Download(ctx context.Context, bucketName, objectName string) (io.ReadCloser, error)

Download retrieves a file from S3.

func (*S3Storage) GetSignedURL

func (s *S3Storage) GetSignedURL(ctx context.Context, bucketName, objectName string, method string, durationMinutes int) (string, error)

GetSignedURL generates a signed URL for S3.

func (*S3Storage) Upload

func (s *S3Storage) Upload(ctx context.Context, bucketName, objectName string, file io.Reader) (string, error)

Upload saves a file to S3.

type S3StorageConfig

type S3StorageConfig struct {
	Region          string `mapstructure:"region"`
	AccessKeyID     string `mapstructure:"access_key_id"`
	SecretAccessKey string `mapstructure:"secret_access_key"`
	Bucket          string `mapstructure:"bucket"`
}

S3StorageConfig holds configuration for S3 storage.

type Storage

type Storage interface {
	Upload(ctx context.Context, bucketName, objectName string, file io.Reader) (string, error)
	Download(ctx context.Context, bucketName, objectName string) (io.ReadCloser, error)
	Delete(ctx context.Context, bucketName, objectName string) error
	GetSignedURL(ctx context.Context, bucketName, objectName string, method string, durationMinutes int) (string, error)
}

Storage defines the interface for file storage operations.

func NewStorage

func NewStorage(ctx context.Context, log *logrus.Logger, cfg config.StorageConfig) (Storage, error)

NewStorage creates a new Storage implementation based on the provided configuration.

Jump to

Keyboard shortcuts

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