Skip to content

Commit 43a35d1

Browse files
committed
Use openAsBlob
1 parent b40c9db commit 43a35d1

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

pages/api/uploads/csv-upload.page.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { readFile } from 'fs/promises';
1+
import { openAsBlob } from 'node:fs';
22
import { NextApiRequest, NextApiResponse } from 'next';
33
import formidable, { IncomingForm } from 'formidable';
44
import { getToken } from 'next-auth/jwt';
5-
import fetch, { File, FormData } from 'node-fetch';
65

76
export const config = {
87
api: {
@@ -54,7 +53,7 @@ const uploadFile = async (
5453
}
5554

5655
const csvFile = new File(
57-
[new Uint8Array(await readFile(file.filepath))],
56+
[await openAsBlob(file.filepath)],
5857
file.originalFilename ?? 'csvFile',
5958
);
6059

pages/api/uploads/upload-person-avatar.page.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { readFile } from 'fs/promises';
1+
import { openAsBlob } from 'node:fs';
22
import { NextApiRequest, NextApiResponse } from 'next';
33
import formidable, { IncomingForm } from 'formidable';
44
import { getToken } from 'next-auth/jwt';
5-
import fetch, { File, FormData } from 'node-fetch';
65

76
export const config = {
87
api: {
@@ -59,7 +58,7 @@ const uploadPersonAvatar = async (
5958

6059
const pictureId = crypto.randomUUID();
6160
const file = new File(
62-
[new Uint8Array(await readFile(avatar.filepath))],
61+
[await openAsBlob(avatar.filepath)],
6362
avatar.originalFilename ?? 'avatar',
6463
);
6564

0 commit comments

Comments
 (0)