Client Helpers
Hooks and helper flows for uploads and downloads.
Hooks
const {
useFiles,
useFile,
useCreateUpload,
useUploadStatus,
useAbortUpload,
useUpdateFile,
useDeleteFile,
} = uploadClient;Helpers
The helper API wraps the common end-to-end flows. It is exposed as a reactive store hook in supported frameworks.
const { useUploadHelpers } = uploadClient;
const helpers = useUploadHelpers();
await helpers.createUploadAndTransfer(file, {
fileKey: `teams/${teamId}/logo`,
onProgress: ({ bytesUploaded, totalBytes }) => {
console.log(bytesUploaded, totalBytes);
},
});createUploadAndTransfer
- Creates an upload.
- Streams the file's content to
PUT /uploads/:uploadId/content, reporting progress, and falls back to a buffered request when the browser cannot stream request bodies. - Returns the published file, or the prepared write for a
batchupload.
downloadFile
const response = await helpers.downloadFile(`teams/${teamId}/logo`);
const blob = await response.blob();It reads GET /files/by-key/content?key=....