File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { readFile } from 'fs/promises ' ;
1+ import { openAsBlob } from 'node:fs ' ;
22import { NextApiRequest , NextApiResponse } from 'next' ;
33import formidable , { IncomingForm } from 'formidable' ;
44import { getToken } from 'next-auth/jwt' ;
5- import fetch , { File , FormData } from 'node-fetch' ;
65
76export 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
Original file line number Diff line number Diff line change 1- import { readFile } from 'fs/promises ' ;
1+ import { openAsBlob } from 'node:fs ' ;
22import { NextApiRequest , NextApiResponse } from 'next' ;
33import formidable , { IncomingForm } from 'formidable' ;
44import { getToken } from 'next-auth/jwt' ;
5- import fetch , { File , FormData } from 'node-fetch' ;
65
76export 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
You can’t perform that action at this time.
0 commit comments