Direct uploads
One request per file, for files up to the direct-upload limit.
await files.bucket('menu').upload('pan-masa-madre.jpg', file, {
contentType: 'image/jpeg', // checked against the bytes
upsert: false, // true replaces an existing file (needs an update policy)
cacheControl: '3600',
metadata: { product: 'pan-masa-madre' },
});The SDK sends POST /object/{bucket}/{path} with the file as the body. The response has the file’s id, size, checksum and scan_status.
What is checked, in order
- The token or key, and that the bucket exists.
- The path’s format.
- The size against the bucket’s
maxFileSizeand the direct-upload limit (413above it: use resumable uploads). - The type, sniffed from the first bytes, against
allowedTypes. - Your
insertpolicy (andupdatewithupsert). - The project’s storage quota.
The object is written to storage with a SHA-256 checksum; the metadata row is written only after the bytes are stored, so a failed upload never leaves a row pointing at nothing.