Skip to content

Commit a345d0d

Browse files
authored
Update blob creation to handle Buffer inputs correctly in createFile (#269)
1 parent 9b4bb64 commit a345d0d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/files.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ async function createFile(file, metadata = {}) {
1515
blob = file;
1616
} else if (Buffer.isBuffer(file)) {
1717
filename = `buffer_${Date.now()}`;
18-
blob = new Blob(file, { type: "application/octet-stream" });
18+
const bytes = new Uint8Array(file);
19+
blob = new Blob([bytes], {
20+
type: "application/octet-stream",
21+
name: filename,
22+
});
1923
} else {
2024
throw new Error("Invalid file argument, must be a Blob, File or Buffer");
2125
}

0 commit comments

Comments
 (0)