Skip to content

Commit

Permalink
Update packages/file/src/adapter/node.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma authored Apr 3, 2024
1 parent 3b6f691 commit 578a099
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions packages/file/src/adapter/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export async function loadFile(url: string): Promise<FileResponse | undefined> {
if (url.startsWith('file://')) {
const data = await readFile(fileURLToPath(url))
const result = await fromBuffer(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 }
}
Expand Down

0 comments on commit 578a099

Please sign in to comment.