Skip to content

Direct uploads

One request per file, for files up to the direct-upload limit.

Applies to EngineCloud
View as Markdown
TypeScript
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

  1. The token or key, and that the bucket exists.
  2. The path’s format.
  3. The size against the bucket’s maxFileSize and the direct-upload limit (413 above it: use resumable uploads).
  4. The type, sniffed from the first bytes, against allowedTypes.
  5. Your insert policy (and update with upsert).
  6. 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.

    Search pages, sections and terms