Documentation
¶
Index ¶
- Variables
- type Driver
- func (d *Driver) Close() error
- 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) PutStream(ctx context.Context, key string, r io.Reader) (int64, error)
- func (d *Driver) URL(ctx context.Context, key string) *PresignedURL
- func (d *Driver) WalkKeys(ctx context.Context, walk func(context.Context, string) error) error
- type PresignedURL
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Ptrs to underlying storage library errors. ErrAlreadyExists = storage.ErrAlreadyExists ErrNotFound = storage.ErrNotFound )
Functions ¶
This section is empty.
Types ¶
type Driver ¶
type Driver struct { // Underlying storage Storage storage.Storage // S3-only parameters Proxy bool Bucket string PresignedCache *ttl.Cache[string, PresignedURL] }
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 ¶
Remove 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.
Click to show internal directories.
Click to hide internal directories.