Documentation
¶
Overview ¶
Package s3 provides a storage implementation for S3
Index ¶
- func StringPointer(s string) *string
- type Config
- type CustomAPIHTTPClient
- type Storage
- func (s *Storage) Delete(ctx context.Context, path string) error
- func (s *Storage) FileSystem() *afero.Afero
- func (s *Storage) Open(ctx context.Context, path string) (io.ReadCloser, error)
- func (s *Storage) OpenWithStat(ctx context.Context, path string) (io.ReadCloser, *storage.Stat, error)
- func (s *Storage) PresignedURL(key string, contentType string) (string, error)
- func (s *Storage) Save(ctx context.Context, content io.Reader, path, checksum, key string, ...) error
- func (s *Storage) SaveQuick(ctx context.Context, content io.Reader, path string) error
- func (s *Storage) Stat(ctx context.Context, path string) (*storage.Stat, error)
- func (s *Storage) Tags(key string) (map[string]string, error)
- func (s *Storage) TempFileSystem() *afero.Afero
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StringPointer ¶
Types ¶
type Config ¶
type Config struct {
// Enabled is a flag to enable or disable the storage
Enabled bool `json:"enabled" koanf:"enabled" default:"false"`
// AccessKeyID is the access key id
AccessKeyID string `json:"accessKeyID" koanf:"accessKeyID"`
// Bucket is the name of the bucket
Bucket string `json:"bucket" koanf:"bucket" default:"yourbucketname"`
// Endpoint is the endpoint to use for the s3 client
Endpoint string `json:"endpoint" koanf:"endpoint"`
// Region is the region to use for the s3 client
Region string `json:"region" koanf:"region" default:"us-region-a"`
// SecretAccessKey is the secret access key
SecretAccessKey string `json:"secretAccessKey" koanf:"secretAccessKey"`
// UploadConcurrency is the number of goroutines to spin up when uploading parts
UploadConcurrency *int64 `json:"uploadConcurrency" koanf:"uploadConcurrency" default:"5"`
// CustomHTTPClient is a custom http client wrapper for s3 interfaces
CustomHTTPClient CustomAPIHTTPClient `json:"-" koanf:"-"`
}
Config is the configuration for Storage
type CustomAPIHTTPClient ¶
CustomAPIHTTPClient is a custom http client wrapper for s3 interfaces
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage wraps AWS S3 storage interface and s3 client pointer
func NewStorage ¶
NewStorage returns a new Storage with the provided configuration
func (*Storage) Delete ¶
Delete deletes path which uses the configured bucket and takes path as input
func (*Storage) FileSystem ¶
FileSystem returns the underlying afero filesystem
func (*Storage) Open ¶
Open opens path for reading and returns a reader which can be used to read the content
func (*Storage) OpenWithStat ¶
func (s *Storage) OpenWithStat(ctx context.Context, path string) (io.ReadCloser, *storage.Stat, error)
OpenWithStat opens the provided path for reading with file stats included
func (*Storage) PresignedURL ¶
PresignedURL returns a URL that provides access to a file for 15 minutes
func (*Storage) Save ¶
func (s *Storage) Save(ctx context.Context, content io.Reader, path, checksum, key string, tags *string) error
Save saves content to path inside of a bucket (bucket is set in the config)
func (*Storage) SaveQuick ¶
Save saves content to path inside of a bucket (bucket is set in the config)
func (*Storage) TempFileSystem ¶
TempFileSystem returns the temporary afero filesystem