Documentation
¶
Index ¶
- Variables
- type FSStore
- func (fs *FSStore) BucketExists(ctx context.Context, bucket string) (bool, error)
- func (fs *FSStore) CreatePublicBucket(ctx context.Context, bucket, region string) error
- func (fs *FSStore) CreateSecureBucket(ctx context.Context, bucket, region string) error
- func (fs *FSStore) Delete(ctx context.Context, bucket, key string) error
- func (fs *FSStore) Download(ctx context.Context, bucket, key string) (io.ReadCloser, error)
- func (fs *FSStore) GenerateDeleteSignedURL(ctx context.Context, bucket, key string, expires time.Duration) (string, error)
- func (fs *FSStore) GenerateGetSignedURL(ctx context.Context, bucket, key string, expires time.Duration) (string, error)
- func (fs *FSStore) GeneratePutSignedURL(ctx context.Context, bucket, key string, expires time.Duration) (string, error)
- func (fs *FSStore) ListObjects(ctx context.Context, bucket, prefix string) ([]string, error)
- func (fs *FSStore) Upload(ctx context.Context, bucket, key string, size int64, body io.Reader) error
- type MinioStore
- func (s *MinioStore) BucketExists(ctx context.Context, bucket string) (bool, error)
- func (s *MinioStore) CreatePublicBucket(ctx context.Context, bucket, region string) error
- func (s *MinioStore) CreateSecureBucket(ctx context.Context, bucket, region string) error
- func (s *MinioStore) Delete(ctx context.Context, bucket, key string) error
- func (s *MinioStore) Download(ctx context.Context, bucket, key string) (io.ReadCloser, error)
- func (s *MinioStore) GenerateDeleteSignedURL(ctx context.Context, bucket, key string, expires time.Duration) (string, error)
- func (s *MinioStore) GenerateGetSignedURL(ctx context.Context, bucket, key string, expires time.Duration) (string, error)
- func (s *MinioStore) GeneratePutSignedURL(ctx context.Context, bucket, key string, expires time.Duration) (string, error)
- func (s *MinioStore) ListObjects(ctx context.Context, bucket, prefix string) ([]string, error)
- func (s *MinioStore) Upload(ctx context.Context, bucket, key string, size int64, body io.Reader) error
- type S3Store
- func (s *S3Store) BucketExists(ctx context.Context, bucket string) (bool, error)
- func (s *S3Store) CreatePublicBucket(ctx context.Context, bucket, region string) error
- func (s *S3Store) CreateSecureBucket(ctx context.Context, bucket, region string) error
- func (s *S3Store) Delete(ctx context.Context, bucket, key string) error
- func (s *S3Store) Download(ctx context.Context, bucket, key string) (io.ReadCloser, error)
- func (s *S3Store) GenerateDeleteSignedURL(ctx context.Context, bucket, key string, expires time.Duration) (string, error)
- func (s *S3Store) GenerateGetSignedURL(ctx context.Context, bucket, key string, expires time.Duration) (string, error)
- func (s *S3Store) GeneratePutSignedURL(ctx context.Context, bucket, key string, expires time.Duration) (string, error)
- func (s *S3Store) ListObjects(ctx context.Context, bucket, prefix string) ([]string, error)
- func (s *S3Store) Upload(ctx context.Context, bucket, key string, size int64, body io.Reader) error
- type Storage
- func NewFS(path string) (Storage, error)
- func NewMinio(ctx context.Context, endpoint, region, accessKey, secretKey string, ...) (Storage, error)
- func NewR2(ctx context.Context, accountID, accessKey, secretKey string) (Storage, error)
- func NewS3(ctx context.Context, region, accessKey, secretKey string) (Storage, error)
- func NewStorageProvider(cfg config.Storage, logger *zerolog.Logger) (Storage, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrOperationNotSupported = errors.New("operation not supported by this storage type")
Functions ¶
This section is empty.
Types ¶
type FSStore ¶
type FSStore struct {
BasePath string
}
FSStore implements the Store interface using the local filesystem.
func (*FSStore) BucketExists ¶
func (*FSStore) CreatePublicBucket ¶
func (*FSStore) CreateSecureBucket ¶
func (*FSStore) GenerateDeleteSignedURL ¶
func (*FSStore) GenerateGetSignedURL ¶
func (*FSStore) GeneratePutSignedURL ¶
func (*FSStore) ListObjects ¶
type MinioStore ¶
func (*MinioStore) BucketExists ¶
func (*MinioStore) CreatePublicBucket ¶
func (s *MinioStore) CreatePublicBucket(ctx context.Context, bucket, region string) error
func (*MinioStore) CreateSecureBucket ¶
func (s *MinioStore) CreateSecureBucket(ctx context.Context, bucket, region string) error
func (*MinioStore) Delete ¶
func (s *MinioStore) Delete(ctx context.Context, bucket, key string) error
func (*MinioStore) Download ¶
func (s *MinioStore) Download(ctx context.Context, bucket, key string) (io.ReadCloser, error)
func (*MinioStore) GenerateDeleteSignedURL ¶
func (s *MinioStore) GenerateDeleteSignedURL(ctx context.Context, bucket, key string, expires time.Duration) (string, error)
TODO: Fix this
func (*MinioStore) GenerateGetSignedURL ¶
func (*MinioStore) GeneratePutSignedURL ¶
func (*MinioStore) ListObjects ¶
type S3Store ¶
type S3Store struct {
Client *s3.Client
PresignClient *s3.PresignClient
// contains filtered or unexported fields
}
S3Store implements the Store interface using the AWS S3 SDK.
func (*S3Store) BucketExists ¶
func (*S3Store) CreatePublicBucket ¶
func (*S3Store) CreateSecureBucket ¶
func (*S3Store) GenerateDeleteSignedURL ¶
func (*S3Store) GenerateGetSignedURL ¶
func (*S3Store) GeneratePutSignedURL ¶
func (*S3Store) ListObjects ¶
type Storage ¶
type Storage interface {
// Upload uploads data from the reader to the specified bucket and key.
Upload(ctx context.Context, bucket, key string, size int64, body io.Reader) error
// Download retrieves the object from the specified bucket and key.
// The caller is responsible for closing the returned io.ReadCloser.
Download(ctx context.Context, bucket, key string) (io.ReadCloser, error)
// Delete removes the object from the specified bucket and key.
Delete(ctx context.Context, bucket, key string) error
// ListObjects lists objects in the specified bucket with the given prefix.
ListObjects(ctx context.Context, bucket, prefix string) ([]string, error)
// GenerateGetSignedURL creates a presigned URL for getting an object.
GenerateGetSignedURL(ctx context.Context, bucket, key string, expires time.Duration) (string, error)
// GeneratePutSignedURL creates a presigned URL for putting an object.
GeneratePutSignedURL(ctx context.Context, bucket, key string, expires time.Duration) (string, error)
// GenerateDeleteSignedURL creates a presigned URL for deleting an object.
GenerateDeleteSignedURL(ctx context.Context, bucket, key string, expires time.Duration) (string, error)
// BucketExists checks if a bucket exists.
BucketExists(ctx context.Context, bucket string) (bool, error)
// CreatePublicBucket creates a bucket (semantics depend on implementation, S3 won't make it world-readable by default).
CreatePublicBucket(ctx context.Context, bucket, region string) error
// CreateSecureBucket creates a bucket with stricter security settings (e.g., encryption, access blocks for S3).
CreateSecureBucket(ctx context.Context, bucket, region string) error
}
Store defines the interface for interacting with different storage backends.
func NewFS ¶
NewFS creates a new Store implementation using the local filesystem. The path provided will be the root directory under which buckets are created as subdirectories.
func NewMinio ¶
func NewMinio(ctx context.Context, endpoint, region, accessKey, secretKey string, useSSL bool) (Storage, error)
NewMinio creates a new Store implementation for MinIO (S3 compatible).
Click to show internal directories.
Click to hide internal directories.