Skip to content

SDK reference

import { upload } from '@dropkit/upload';
const { data, error } = await upload(file, {
key: 'pk_live_...', // required
endpoint: 'https://api.dropkit.app', // optional
metadata: { user: '123' }, // optional
onProgress: (bytes, total) => {}, // optional
signal: controller.signal, // optional
});

Response shape

// success
{ data: { id, url, name, size, type }, error: null }
// failure
{ data: null, error: { code, message, fix? } }

Error codes

codemeaning
missing_keyThe key option was not provided
missing_authThe bearer header was missing on the API call
invalid_keyKey was not recognized
origin_not_allowedThe browser’s origin isn’t in the project allowlist
size_out_of_rangeFile size is 0 or exceeds 5 GiB
upload_failedThe file upload PUT request failed
needs_secret_keyOperation requires sk_live_

Aborting

const ctrl = new AbortController();
upload(file, { key, signal: ctrl.signal });
ctrl.abort();