File record represents a file uploaded to Sublay’s storage system. Files can be attached to users (avatars, banners), entities, events, comments, chat messages, conversations (avatars) or spaces. An image uploaded as an image (an images list, a slot such as avatarFile or coverFile, or Upload Image) is processed, and carries an image extension with variants at multiple sizes. A file uploaded in a files list or through Upload File is stored as uploaded.
A File has the same shape everywhere it is returned: embedded in a record, from both storage uploads, and from Fetch File.
A record’s files are uploaded, replaced and removed through that record’s own requests: a user’s or space’s avatar and banner, a conversation’s avatar and an event’s cover through their create and update (avatarFile, bannerFile, coverFile, removeFileIds); an entity’s or event’s images and files through their create and update (removeFileIds on update); a comment’s or chat message’s images and files on create, removed with the comment or message. Delete File refuses all of them with 409 storage/file-attached. The files a deleted comment, or a soft-deleted entity or event, kept belong to nothing, and their owner deletes them through Delete File.
File links
Every link in a File (originalPath, and each variant’s publicPath) is a signed link that stops working at the File’s linksExpireAt, 24 to 48 hours after it was read. Within one UTC day the same file always gets the same link, so browser and image caches keep working.
A file’s links come only with a record the viewer can see. To get fresh links, read the record again, or send the file’s id to Refresh File Links, which answers only for files the viewer can still see. Store a file’s id, never its link. In React and React Native, render a File through useFileLinks and its links are refreshed when they expire; the components installed with sublay add already do this for avatars.
A file can be seen by whoever can see the record it belongs to:
A file whose record was deleted is shown to nobody. A service key sees what the user named in
actingUserId sees; naming nobody, it sees files that belong to nothing and those anyone can see.
File
FileImage
For processed images, theimage field contains processing results and variant URLs.
FileImageVariant
Each entry inFileImage.variants has this shape:

