Standard Upload
After creating a bucket, you can start uploading and managing objects within it. The easiest way to upload a new object is through the standard upload. It supports objects that do not exceed 100 MB in size.
const result = await client.storage.uploadObject({ bucketName: 'documents', key: `invoices/${exampleObject.name}`, body: exampleObject, contentType: exampleObject.type, cacheControl: 'private, max-age=0', attributes: { category: 'invoice' }}) if (result.error) { throw result.error} console.log(result.data.object)console.log(result.data.uploaded)Multipart Upload
For files exceeding 100mb you should use the Multipart upload, by creating the multipart upload and then sending all the parts. The content type, Cache-Control value and attributes should be set when creating the multipart upload.
const result = await client.storage.startMultipartUpload({ bucketName: 'videos', key: 'releases/product-tour.mp4', contentType: 'video/mp4', cacheControl: 'public, max-age=86400', attributes: { release: 'summer-2026' } }) if (result.error) { throw result.error} const uploadId = result.data.upload_idUpload a part
Upload all the parts with the upload id from the initalized multipart upload
const CHUNK_SIZE = 5 * 1024 * 1024 // 5 MB chunkslet start = 0let partNumber = 1 while (start < selectedFile.size) { const end = Math.min(start + CHUNK_SIZE, selectedFile.size) const part = selectedFile.slice(start, end) const result = await client.storage.uploadMultipartPart({ bucketName: 'videos', uploadId, partNumber, body: part, contentLength: part.size }) if (result.error) { throw result.error } start = end partNumber += 1}Complete Multipart Upload
After uploading every part, complete the multipart upload to create the final object.
By default every part you uploaded will be used to create the final object, if you wish to omit any you can pass the partNumbers param. If its included only the selected parts will be used
The maximum numbers of parts is 10 000.
const result = await client.storage.completeMultipartUpload({ bucketName: 'videos', uploadId }) if (result.error) { throw result.error} console.log(result.data.uploaded)