alepha@docs:~/docs/packages/alepha/api$
cat files.md | pretty1 min read
Last commit:
#Alepha - Api Files
#Installation
Part of the alepha package. Import from alepha/api/files.
npm install alepha
#Overview
File storage with metadata: the $storage primitive plus the endpoints,
querying and retention that a database makes possible.
Declare a place to keep files with $storage. Every upload writes a files
row next to the blob, which is what powers paginated listing, TTL expiry,
tags, checksums and creator tracking.
ts
1class Media {2 avatars = $storage({ mimeTypes: ["image/png"], maxSize: 2 });3}4 5const stored = await this.avatars.upload(file, { user });6stored.id; // hand this to GET /api/files/:id
Features:
$storageprimitive with MIME/size constraints and default TTL- Upload/download HTTP endpoints, ETag-aware
- Paginated, filterable file queries
- TTL-based expiration swept by
api:files:purgeFiles - Storage statistics for the admin UI
Blobs without a database are a FileStorageProvider concern — see
alepha/bucket.
#API Reference
#Primitives
$storage— Declares a named, constrained place to keep files.
#Providers
DefaultStorage— Thedefaultstorage.FileAccessProvider— Authorization policy for file reads served throughFileController.streamFile.StorageMultipartCapProvider— Lets the targeted$storagedecide how many bytes a request may carry.