Documentation
¶
Overview ¶
Package blob stores files (documents, screenshots, confirmation pages) in a directory volume or an S3-compatible bucket. Sealed encrypts every object for its user (platform/crypto), so the storage only ever sees ciphertext.
Index ¶
Constants ¶
const MaxObject = 64 << 20
MaxObject bounds one object (uploads have their own, smaller limits).
Variables ¶
var ( // ErrNotFound reports a missing object. ErrNotFound = errors.New("blob not found") // ErrBadKey reports a key that is not a safe relative path. ErrBadKey = errors.New("invalid blob key") // ErrTooLarge reports an object above MaxObject. ErrTooLarge = errors.New("blob too large") )
Functions ¶
Types ¶
type Dir ¶
type Dir struct {
// contains filtered or unexported fields
}
Dir stores objects as files below one directory. All access goes through os.Root, so no key can leave it (symlinks included); writes go to a temporary file first and are renamed into place.
type S3 ¶
type S3 struct {
// contains filtered or unexported fields
}
S3 stores objects in a bucket of an S3-compatible service (AWS, MinIO, Garage, Hetzner, …).
type S3Credentials ¶
S3Credentials are the access key pair of a bucket.
type Sealed ¶
type Sealed struct {
// contains filtered or unexported fields
}
Sealed stores the objects of each user under users/<id>/, encrypted with the user's data key and bound to the key, so an object moved to another key or user does not open.
type Sealer ¶
type Sealer interface {
Seal(ctx context.Context, userID uuid.UUID, purpose string, plaintext []byte) ([]byte, error)
Open(ctx context.Context, userID uuid.UUID, purpose string, ciphertext []byte) ([]byte, error)
}
Sealer encrypts per user (crypto.Envelope).
type Store ¶
type Store interface {
Put(ctx context.Context, key string, data []byte) error
Get(ctx context.Context, key string) ([]byte, error)
// Delete removes an object; a missing one is not an error.
Delete(ctx context.Context, key string) error
}
Store keeps opaque objects by key.
func Open ¶
func Open(raw string, creds S3Credentials) (Store, error)
Open returns the store a URL names: file:///var/lib/getafjob/blobs or s3://bucket/prefix?endpoint=https://s3.example.org®ion=eu-central-1.