Files
File fields do not store bytes in Mongo. The client:
- Starts an upload session (declared
filename,contentType,size). PUTs the bytes to the returned presigned URL (S3/MinIO).- Completes the session so the file is attached to the record.
The SDKs wrap this in uploadFile.
The record must already exist. Create the document first, then upload.
JavaScript
Section titled “JavaScript”uploadFile accepts a Blob, ArrayBuffer, or Uint8Array.
const bytes = new Uint8Array(await file.arrayBuffer());const meta = await posts.uploadFile(recordId, 'attachment', { data: bytes, size: bytes.byteLength, filename: 'photo.jpg', contentType: 'image/jpeg',});
const download = await posts.getDownloadUrl(recordId, 'attachment', meta.id);console.log(download.url);
await posts.deleteFile(recordId, 'attachment', meta.id);final bytes = await File('photo.jpg').readAsBytes();final meta = await posts.uploadFile( recordId, 'attachment', data: Stream.value(bytes), length: bytes.length, filename: 'photo.jpg', contentType: 'image/jpeg',);
final download = await posts.getDownloadUrl(recordId, 'attachment', meta.id);print(download.url);
await posts.deleteFile(recordId, 'attachment', meta.id);| Step | Method | Path |
|---|---|---|
| Start | POST | /api/p/:projectId/:table/:recordId/files/:field/upload-sessions |
| Complete | POST | /api/p/:projectId/:table/:recordId/files/:field/:fileId/complete |
| Download URL | GET | /api/p/:projectId/:table/:recordId/files/:field/:fileId |
| Delete | DELETE | same as download |
Enable the upload, download, and fileDelete endpoints. Add file rules (fileSizeLimit, fileMimeType, fileExtensionAllow) on upload.
The platform also enforces a global FILE_MAX_BYTES cap.