You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
profileImageUpload: async(_,{ file }: {file: File})=>{// get readableStream from blobconstreadableStream=file.stream()conststream=readableStream.getReader()console.log('file',file.type)let_file: Buffer|undefinedwhile(true){// for each iteration: value is the next blob fragmentconst{ done, value }=awaitstream.read()if(done){// no more data in the streamconsole.log('all blob processed.')break}if(value)_file=Buffer.concat([_file||Buffer.alloc(0),Buffer.from(value)])}if(_file){constimage=sharp(_file)constmetadata=awaitimage.metadata()console.log(metadata,'metadata')try{constimage=awaitsharp(_file).resize(600,600).webp().toBuffer()fs.writeFileSync('test.webp',image)console.log(image,'image')}catch(error){console.error(error)}}return'a'},
The text was updated successfully, but these errors were encountered:
stackoverflow
另一个关于此的讨论
后者给出了yoga的另一种文件上传的写法
The text was updated successfully, but these errors were encountered: