initial commit
This commit is contained in:
commit
1253955070
75 changed files with 13972 additions and 0 deletions
29
api/internal/blobstore/blobstore.go
Normal file
29
api/internal/blobstore/blobstore.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
// Package blobstore stores the bytes of uploaded pictures. Keeping it behind an
|
||||
// interface means the local filesystem can later be replaced by object storage
|
||||
// without changing the upload handler.
|
||||
package blobstore
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrNotFound is returned when a key has no stored object.
|
||||
ErrNotFound = errors.New("blob not found")
|
||||
// ErrTooLarge is returned when the payload exceeds the configured limit.
|
||||
ErrTooLarge = errors.New("blob exceeds maximum size")
|
||||
)
|
||||
|
||||
// BlobStore saves and serves opaque byte payloads addressed by key.
|
||||
type BlobStore interface {
|
||||
// Put stores the contents of r under key and returns the number of bytes
|
||||
// written. It must not read more than maxBytes from r.
|
||||
Put(ctx context.Context, key string, r io.Reader, maxBytes int64) (int64, error)
|
||||
// Get opens the object stored under key. The caller closes the reader.
|
||||
Get(ctx context.Context, key string) (io.ReadCloser, error)
|
||||
// Delete removes the object stored under key. Deleting a missing key is not
|
||||
// an error.
|
||||
Delete(ctx context.Context, key string) error
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue