JavaScript client

Uploads

Create an upload intent, upload bytes, and complete an asset.

const intent = await client.createUpload({
  filename: 'portrait.webp',
  contentType: 'image/webp',
  size: bytes.byteLength,
  visibility: 'public',
  galleryIds: ['gallery_uuid'],
});

const response = await fetch(intent.uploadUrl, {
  method: 'PUT',
  headers: { 'Content-Type': intent.contentType ?? 'image/webp' },
  body: bytes,
});
if (!response.ok) throw new Error(`Upload failed: ${response.status}`);

const asset = await client.completeUpload(intent.intentId);

The API validates the completed object. A successful storage PUT is not the same as a completed DeGallery asset. Completion is safe to retry for the same intent.

Keep uploads in trusted server code when the request uses a secret API key. Browser uploads should use a short-lived intent created by your server or an explicitly supported public flow.