Documentation
¶
Overview ¶
Package storage provides basic storage interfaces for storage providers to write / read objects to and from
Index ¶
- Variables
- type Disk
- func (d *Disk) Close() error
- func (d *Disk) Download(ctx context.Context, key string, opts *objects.DownloadFileOptions) (*objects.DownloadFileMetadata, io.ReadCloser, error)
- func (d *Disk) GetPresignedURL(ctx context.Context, key string) (string, error)
- func (d *Disk) GetScheme() *string
- func (d *Disk) ManagerUpload(ctx context.Context, files [][]byte) error
- func (d *Disk) Upload(ctx context.Context, r io.Reader, opts *objects.UploadFileOptions) (*objects.UploadedFileMetadata, error)
- type S3Options
- type S3Store
- func (s *S3Store) Close() error
- func (s *S3Store) Download(ctx context.Context, key string, opts *objects.DownloadFileOptions) (*objects.DownloadFileMetadata, io.ReadCloser, error)
- func (s *S3Store) Exists(ctx context.Context, key string) (bool, error)
- func (s *S3Store) GetPresignedURL(ctx context.Context, key string) (string, error)
- func (s *S3Store) GetPresignedURLWithCustomDuration(ctx context.Context, key string, expires time.Duration) (string, error)
- func (s *S3Store) GetScheme() *string
- func (s *S3Store) ManagerUpload(ctx context.Context, files [][]byte) error
- func (s *S3Store) Upload(ctx context.Context, r io.Reader, opts *objects.UploadFileOptions) (*objects.UploadedFileMetadata, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidS3Bucket is returned when an invalid s3 bucket is provided ErrInvalidS3Bucket = errors.New("invalid s3 bucket provided") // ErrInvalidFolderPath is returned when an invalid folder path is provided ErrInvalidFolderPath = errors.New("invalid folder path provided") )
Functions ¶
This section is empty.
Types ¶
type Disk ¶
type Disk struct {
Scheme string
// contains filtered or unexported fields
}
func NewDiskStorage ¶
func (*Disk) Download ¶
func (d *Disk) Download(ctx context.Context, key string, opts *objects.DownloadFileOptions) (*objects.DownloadFileMetadata, io.ReadCloser, error)
Download is used to download a file from the storage backend TODO: Implement this method
func (*Disk) GetPresignedURL ¶
GetPresignedURL is used to get a presigned URL for a file in the storage backend TODO: Implement this method
func (*Disk) ManagerUpload ¶
ManagerUpload uploads multiple files to disk TODO: Implement this method
type S3Options ¶
type S3Options struct {
// Bucket to store objects in
Bucket string
// DebugMode will log all requests and responses
DebugMode bool
// UsePathStyle allows you to enable the client to use path-style addressing, i.e., https://s3.amazonaws.com/BUCKET/KEY .
// by default, the S3 client will use virtual hosted bucket addressing when possible( https://BUCKET.s3.amazonaws.com/KEY ).
UsePathStyle bool
// ACL should only be used if the bucket supports ACL
ACL types.ObjectCannedACL
// KeyNamespace is used to prefix all keys with a namespace
KeyNamespace string
}
S3Options is used to configure the S3Store
type S3Store ¶
type S3Store struct {
Client *s3.Client
Opts S3Options
PresignClient *s3.PresignClient
Downloader *manager.Downloader
Uploader *manager.Uploader
ObjExistsWaiter *s3.ObjectExistsWaiter
ObjNotExistsWaiter *s3.ObjectNotExistsWaiter
ACL types.ObjectCannedACL
CacheControl string
Scheme string
}
S3Store is a store that uses S3 as the backend
func NewS3FromConfig ¶
NewS3FromConfig creates a new S3Store from the provided configuration
func (*S3Store) Download ¶
func (s *S3Store) Download(ctx context.Context, key string, opts *objects.DownloadFileOptions) (*objects.DownloadFileMetadata, io.ReadCloser, error)
Download an object from S3 and return the metadata and a reader
func (*S3Store) GetPresignedURL ¶
PresignedURL returns a URL that provides access to a file for 15 minutes
func (*S3Store) GetPresignedURLWithCustomDuration ¶
func (s *S3Store) GetPresignedURLWithCustomDuration(ctx context.Context, key string, expires time.Duration) (string, error)
PresignedURL returns a URL that provides access to a file with a custom duration
func (*S3Store) ManagerUpload ¶
ManagerUpload uploads multiple files to S3