Skip to content

Commit

Permalink
fix(file): data is not an arraybuffer (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
idranme authored Apr 3, 2024
1 parent 02e260f commit 59db019
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/file/src/adapter/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export async function loadFile(url: string): Promise<FileResponse | undefined> {
if (url.startsWith('file://')) {
const data = await readFile(fileURLToPath(url))
const result = await fromBuffer(data)
return { mime: result?.mime, filename: basename(url), data }
// https://stackoverflow.com/questions/8609289/convert-a-binary-nodejs-buffer-to-javascript-arraybuffer#answer-31394257
const buffer = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength)
return { mime: result?.mime, filename: basename(url), data: buffer }
}
}

0 comments on commit 59db019

Please sign in to comment.