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, opts *objects.DownloadFileOptions) (*objects.DownloadFileMetadata, error)
- func (d *Disk) GetPresignedURL(ctx context.Context, key string, expires time.Duration) (string, error)
- func (d *Disk) GetScheme() *string
- func (d *Disk) ListBuckets() ([]string, error)
- 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 DiskOption
- type DiskOptions
- type S3Option
- func WithAWSConfig(cfg aws.Config) S3Option
- func WithAccessKeyID(accessKeyID string) S3Option
- func WithBucket(bucket string) S3Option
- func WithEndpoint(endpoint string) S3Option
- func WithPresignedURLTimeout(timeout int) S3Option
- func WithRegion(region string) S3Option
- func WithSecretAccessKey(secretAccessKey string) S3Option
- func WithUseSSL(useSSL bool) S3Option
- type S3Options
- type S3Store
- func (s *S3Store) Close() error
- func (s *S3Store) Delete(ctx context.Context, key string) error
- func (s *S3Store) Download(ctx context.Context, opts *objects.DownloadFileOptions) (*objects.DownloadFileMetadata, error)
- func (s *S3Store) Exists(ctx context.Context, key string) (bool, error)
- func (s *S3Store) GetPresignedURL(ctx context.Context, key string, expires time.Duration) (string, error)
- func (s *S3Store) GetScheme() *string
- func (s *S3Store) GetTags(ctx context.Context, key string) (map[string]string, error)
- func (s *S3Store) HeadObj(ctx context.Context, key string) (*s3.HeadObjectOutput, error)
- func (s *S3Store) ListBuckets() ([]string, error)
- func (s *S3Store) ManagerUpload(ctx context.Context, files [][]byte) error
- func (s *S3Store) Tag(ctx context.Context, key string, tags map[string]string) 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") // ErrMissingRequiredAWSParams is returned when required AWS parameters are missing ErrMissingRequiredAWSParams = errors.New("missing required AWS parameters") )
Functions ¶
This section is empty.
Types ¶
type Disk ¶
type Disk struct {
// Scheme is the scheme of the storage backend
Scheme string
// Opts is the options for the disk storage
Opts *DiskOptions
// contains filtered or unexported fields
}
func NewDiskStorage ¶
func NewDiskStorage(opts *DiskOptions) (*Disk, error)
func (*Disk) Download ¶
func (d *Disk) Download(ctx context.Context, opts *objects.DownloadFileOptions) (*objects.DownloadFileMetadata, error)
Download is used to download a file from the storage backend
func (*Disk) GetPresignedURL ¶
func (d *Disk) GetPresignedURL(ctx context.Context, key string, expires time.Duration) (string, error)
GetPresignedURL is used to get a presigned URL for a file in the storage backend TODO: Implement this method
func (*Disk) ListBuckets ¶ added in v0.3.1
ListBuckets lists the local bucket if it exists
func (*Disk) ManagerUpload ¶
ManagerUpload uploads multiple files to disk TODO: Implement this method
type DiskOption ¶ added in v0.3.1
type DiskOption func(*DiskOptions)
func WithLocalBucket ¶ added in v0.3.1
func WithLocalBucket(bucket string) DiskOption
WithLocalBucket is a DiskOption that sets the bucket for the disk storage which equates to a folder on the file system
func WithLocalKey ¶ added in v0.3.1
func WithLocalKey(key string) DiskOption
WithLocalKey specifies the name of the file in the local folder
type DiskOptions ¶ added in v0.3.1
func NewDiskOptions ¶ added in v0.3.1
func NewDiskOptions(opts ...DiskOption) *DiskOptions
NewDiskOptions returns a new DiskOptions struct
type S3Option ¶ added in v0.3.1
type S3Option func(*S3Options)
S3Option is a function that modifies S3Options
func WithAWSConfig ¶ added in v0.3.1
WithAWSConfig sets the AWS configuration for S3Options
func WithAccessKeyID ¶ added in v0.3.1
WithAccessKeyID sets the access key ID for S3Options
func WithBucket ¶ added in v0.3.1
WithBucket sets the bucket for S3Options
func WithEndpoint ¶ added in v0.3.1
WithEndpoint sets the endpoint for S3Options
func WithPresignedURLTimeout ¶ added in v0.3.1
WithPresignedURLTimeout sets the presigned URL timeout for S3Options
func WithRegion ¶ added in v0.3.1
WithRegion sets the region for S3Options
func WithSecretAccessKey ¶ added in v0.3.1
WithSecretAccessKey sets the secret access key for S3Options
func WithUseSSL ¶ added in v0.3.1
WithUseSSL sets the use SSL flag for S3Options
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
// Region is the region to use for the S3 client
Region string
// AccessKeyID is the access key ID to use for the S3 client
AccessKeyID string
// SecretAccessKey is the secret access key to use for the S3 client
SecretAccessKey string
// Endpoint is the endpoint to use for the S3 client
Endpoint string
// UseSSL is a flag to determine if the S3 client should use SSL
UseSSL bool
// PresignURLTimeout is the timeout for presigned URLs
PresignedURLTimeout int
// AWSConfig is the AWS configuration to use for the S3 client
AWSConfig aws.Config
}
S3Options is used to configure the S3Store
func NewS3Options ¶ added in v0.3.1
NewS3Options creates a new S3Options instance with the provided options
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
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, opts *objects.DownloadFileOptions) (*objects.DownloadFileMetadata, error)
Download an object from S3 and return the metadata and a reader - the reader must be closed after use and is the responsibiolity of the caller
func (*S3Store) GetPresignedURL ¶
func (s *S3Store) GetPresignedURL(ctx context.Context, key string, expires time.Duration) (string, error)
PresignedURL returns a URL that provides access to a file for 15 minutes
func (*S3Store) ListBuckets ¶ added in v0.3.1
ListBuckets lists the buckets in the current account.
func (*S3Store) ManagerUpload ¶
ManagerUpload uploads multiple files to S3