Skip to main content
The storage module uploads files and images to managed cloud storage and returns proxy URLs, plus reads and deletes existing files. Uploads are sent as multipart/form-data — pass a browser File (e.g. from an <input type="file">) or a Blob. There is no Uint8Array + mimeType path; the browser supplies the content type.
Uploads are attributed to the logged-in user automatically (from the token) — there is no userId param. A user may delete files they own; reads are project-scoped.

uploadFile

Uploads a generic file (PDF, video, document, …) without server-side processing.
Blob | File
required
The file to upload, as a browser File or Blob.
string[]
required
Storage path segments. The file is stored under the joined path with a UUID sub-folder appended, e.g. ["documents", "reports"] → documents/reports/<uuid>/<filename>. A folder that is, or contains, . or .. is refused with a 400.
string
Filename for the multipart part. Defaults to the File.name, or "upload".
number
Display order when a record has multiple attachments, from 0 to 10000.
object
Custom key-value data stored alongside the file record.
string
Associates the file with an entity for cascade deletion. Only one of entityId / commentId / spaceId may be set. Only the entity’s author can attach to it.
string
Associates the file with a comment for cascade deletion. Only the comment’s author can attach to it.
string
Associates the file with a space.
Naming a record in entityId or commentId needs the right to update it. When the caller may not, the upload is refused with 403 storage/unauthorized (Not authorized to attach a file to this entity., naming the record type). A record that doesn’t exist or counts as missing gets 404 (storage/entity-not-found or storage/comment-not-found): a deleted record, an entity removed by moderation and a comment its author deleted all count as missing. Nothing is stored on either refusal. Returns — Promise<UploadFileResponse>:

uploadImage

Uploads an image, processes it server-side, and stores the original plus all requested variants. The imageOptions object is a discriminated union on mode — the other fields depend on the mode you pick.
Blob | File
required
The image to upload, as a browser File or Blob. Must be a format the server can process.
ImageOptions
required
Image-processing configuration — a discriminated union on mode. The supported modes and their required fields:All modes also accept optional quality (1–100), format (webp | jpeg | png | original), stripExif (boolean), and fit (cover | contain | inside | outside). Dimension/size values are 50–10000.
string
Filename for the multipart part. Defaults to the File.name, or "upload".
string[]
Folder segments for the stored image. The new file’s id is always added after them (<pathParts>/<fileId>/<filename>). Defaults to ["images"]. A folder that is, or contains, . or .. (also written %2e%2e), or that contains ?, # or an encoded slash (%2f, %5c), is refused with a 400.
string
Associates the image with an entity. Only one of entityId / commentId / spaceId / eventId may be set. Only the entity’s author can attach to it.
string
Associates the image with a comment. Only the comment’s author can attach to it.
string
Associates the image with a space.
string
Associates the image with an event. Most apps attach event images inline via sublay.events.createEvent/updateEvent (cover / gallery); use this only to attach an image to an existing event out-of-band. Only one of the event’s hosts can attach to it.
Naming a record in entityId, commentId or eventId needs the right to update it. When the caller may not, the upload is refused with 403 storage/unauthorized (Not authorized to attach a file to this entity., naming the record type). A record that doesn’t exist or counts as missing gets 404 (storage/entity-not-found, storage/comment-not-found or storage/event-not-found): a deleted record, an entity removed by moderation and a comment its author deleted all count as missing. Nothing is stored on either refusal. Returns — Promise<UploadImageResponse>:

getFile

Fetches a file’s metadata and proxy URLs by ID. For images, an image extension (variants, processing details) is included. Reads are project-scoped.
string
required
The ID of the file to retrieve.
Returns — Promise<GetFileResponse> — a flat projection carrying fileId, type, originalPath, originalSize, originalMimeType, position, metadata, createdAt/updatedAt, the optional association ids (userId, entityId, commentId, spaceId), and — for images — an image object with variants, processingStatus, format, quality, and exifStripped.

deleteFile

Deletes a file record and removes all associated storage objects (for images, every generated variant too).
string
required
The ID of the file to delete.
Returns — Promise<void>
The call only succeeds when the logged-in user owns the file; otherwise it returns 403.