Documentation
¶
Index ¶
Constants ¶
const ( TypeFilesystem = "filesystem" TypeS3 = "s3" )
Backend type names.
const DefaultProfilePicture = "default-profile-picture"
DefaultProfilePicture is the bundled fallback image served when a user has no custom profile picture.
Variables ¶
var ErrNotFound = errors.New("storage: object not found")
ErrNotFound reports a missing object.
Functions ¶
func IsNotExist ¶
IsNotExist reports whether err came from a missing object.
Types ¶
type BundledImages ¶
type BundledImages struct {
// contains filtered or unexported fields
}
BundledImages is the read-only view of images seeded from the frontend asset bundle into the blob store.
func SeedBundledImages ¶
SeedBundledImages copies bundled images from sourceDir into the blob store and returns the seeded set. A missing sourceDir (fresh checkouts, tests) seeds nothing.
type ObjectInfo ¶
type ObjectInfo struct {
Path string
Size int64
ModTime os.FileInfo // nil for S3 listings without the field
}
ObjectInfo describes one stored object in a List result.
type S3Config ¶
type S3Config struct {
Bucket string
Region string
Endpoint string
AccessKeyID string
SecretAccessKey string
ForcePathStyle bool
Root string
}
S3Config selects the bucket, endpoint, and credentials.
type Store ¶
type Store interface {
Save(ctx context.Context, path string, data io.Reader) error
Open(ctx context.Context, path string) (io.ReadCloser, int64, error)
Delete(ctx context.Context, path string) error
DeleteAll(ctx context.Context, prefix string) error
List(ctx context.Context, prefix string) ([]ObjectInfo, error)
Type() string
}
Store is the blob backend contract. Paths are root-relative and use slashes.
func New ¶
func New(cfg config.StorageConfig) (Store, error)
New selects S3 when an endpoint is set, otherwise filesystem storage.
func NewFilesystemStorage ¶
NewFilesystemStorage builds a filesystem backend rooted at rootPath.
func NewS3Storage ¶
NewS3Storage builds an S3 backend with static credentials.