Add type, size, and arrayBuffer properties to the File object

This commit is contained in:
2026-03-31 18:49:15 +02:00
parent 360d4c03cb
commit 2952798e4f

View File

@@ -14,11 +14,14 @@ function createTestFile(bytes: Uint8Array | Buffer, name: string, type: string):
const arrayBuffer = new ArrayBuffer(bytes.byteLength);
new Uint8Array(arrayBuffer).set(bytes);
return Object.assign(new Blob([arrayBuffer], { type }), {
return {
name,
type,
lastModified: Date.now(),
webkitRelativePath: ""
}) as File;
size: arrayBuffer.byteLength,
webkitRelativePath: "",
arrayBuffer: async () => arrayBuffer.slice(0)
} as File;
}
describe("model import", () => {