Here is my code:
public uploadFiles = async (folderName: string, files: Blob[]) => {
const folderId: string = await this.getFolderId(folderName);
for (const file of files) {
const stream: Readable = await blobToReadable(file);
const attributes: UploadFileRequestBodyAttributesField = {
name: file.name,
parent: { id: folderId }
}
await this.boxClient.uploads.uploadFile({ attributes, file: stream });
}
}
const blobToReadable = async (blob: Blob): Promise<Readable> => {
const buffer: Buffer = Buffer.from(await blob.arrayBuffer());
const stream = Readable.from(buffer);
return stream;
}
I am using Bun.js instead of node. folderId is correct and the file is converted correctly from Blob to Readable