Documentation ¶
Index ¶
- func IsAlreadyExist(err error) bool
- func IsInvalidKey(err error) bool
- func IsNotFound(err error) bool
- type Driver
- func (d *Driver) Delete(ctx context.Context, key string) error
- func (d *Driver) Get(ctx context.Context, key string) ([]byte, error)
- func (d *Driver) GetStream(ctx context.Context, key string) (io.ReadCloser, error)
- func (d *Driver) Has(ctx context.Context, key string) (bool, error)
- func (d *Driver) ProbeCSPUri(ctx context.Context) (string, error)
- func (d *Driver) Put(ctx context.Context, key string, value []byte) (int, error)
- func (d *Driver) PutFile(ctx context.Context, key, filepath, contentType string) (int64, error)
- func (d *Driver) URL(ctx context.Context, key string) *PresignedURL
- func (d *Driver) WalkKeys(ctx context.Context, walk func(string) error) error
- type PresignedURL
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsAlreadyExist ¶ added in v0.16.0
IsAlreadyExist returns whether error is an already-exists type error returned by the underlying storage library.
func IsInvalidKey ¶ added in v0.17.0
IsInvalidKey returns whether error is an invalid-key type error returned by the underlying storage library.
func IsNotFound ¶ added in v0.16.0
IsNotFound returns whether error is a not-found error type returned by the underlying storage library.
Types ¶
type Driver ¶
type Driver struct { // Underlying storage Storage storage.Storage // S3-only parameters Proxy bool Bucket string PresignedCache *ttl.Cache[string, PresignedURL] RedirectURL string }
Driver wraps a kv.KVStore to also provide S3 presigned GET URLs.
func AutoConfig ¶
func NewFileStorage ¶ added in v0.6.0
func NewS3Storage ¶ added in v0.6.0
func (*Driver) Delete ¶
Delete attempts to remove the supplied key (and corresponding value) from storage.
func (*Driver) GetStream ¶
GetStream returns an io.ReadCloser for the value bytes at key in the storage.
func (*Driver) ProbeCSPUri ¶ added in v0.11.1
ProbeCSPUri returns a URI string that can be added to a content-security-policy to allow requests to endpoints served by this driver.
If the driver is not backed by non-proxying S3, this will return an empty string and no error.
Otherwise, this function probes for a CSP URI by doing the following:
- Create a temporary file in the S3 bucket.
- Generate a pre-signed URL for that file.
- Extract '[scheme]://[host]' from the URL.
- Remove the temporary file.
- Return the '[scheme]://[host]' string.
func (*Driver) PutFile ¶ added in v0.17.0
PutFile moves the contents of file at path, to storage.Driver{} under given key (with content-type if supported).