We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3c7bdfd commit 22ebdc2Copy full SHA for 22ebdc2
src/uploads.ts
@@ -114,7 +114,12 @@ export async function toFile(
114
const blob = await value.blob();
115
name ||= new URL(value.url).pathname.split(/[\\/]/).pop() ?? 'unknown_file';
116
117
- return new File([blob as any], name, options);
+ // we need to convert the `Blob` into an array buffer because the `Blob` class
118
+ // that `node-fetch` defines is incompatible with the web standard which results
119
+ // in `new File` interpreting it as a string instead of binary data.
120
+ const data = isBlobLike(blob) ? [(await blob.arrayBuffer()) as any] : [blob];
121
+
122
+ return new File(data, name, options);
123
}
124
125
const bits = await getBytes(value);
0 commit comments