storage

package
v0.0.0-...-81e723e Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetUploadConfig

func GetUploadConfig() *config.UploadConfig

GetUploadConfig retrieves the global upload configuration

func Init

func Init(storageCfg *config.StorageConfig, uploadCfg *config.UploadConfig) error

Init initializes the storage provider and upload configuration globally

Types

type S3Storage

type S3Storage struct {
	Bucket  string
	Client  *s3.S3
	BaseURL string
}

func NewS3Storage

func NewS3Storage(bucket, region, baseURL, accessKey, secretKey string) *S3Storage

NewS3Storage initializes a new S3-compatible storage instance

func (*S3Storage) Delete

func (s *S3Storage) Delete(fileName string) error

Delete removes a file from the S3 bucket

func (*S3Storage) Get

func (s *S3Storage) Get(fileName string) (string, error)

Get generates a public URL for the file

func (*S3Storage) Upload

func (s *S3Storage) Upload(fileName string, fileContent io.Reader, contentType string) (string, error)

Upload uploads a file to the S3 bucket

type Storage

type Storage interface {
	Upload(fileName string, fileContent io.Reader, contentType string) (string, error) // Uploads a file and returns its URL
	Get(fileName string) (string, error)                                               // Gets the file URL
	Delete(fileName string) error                                                      // Deletes the file
}

Storage is the generic interface for file storage

func GetManager

func GetManager() Storage

GetManager retrieves the global storage instance

func NewStorageProvider

func NewStorageProvider(storageCfg *config.StorageConfig) (Storage, error)

NewStorageProvider initializes the appropriate storage provider

Jump to

Keyboard shortcuts

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