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
{{ message }}
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.
const formidable = require('formidable')
module.exports = {
path: `/company/:id/file`,
method: 'POST',
render: async (req:any, res:any) => {
try {
let url = await upload(req)
res.status(200).send({ url })
} catch(e) {
res.status(500).send(e)
}
}
}
function upload(req:any) {
let form = new formidable.IncomingForm()
return new Promise((resolve, rej) => {
form.parse(req, (err, fields, files) => {
if (files.file) resolve(files.file.name)
else rej(err)
})
})
}
error
Error: MultipartParser.end(): stream ended unexpectedly: state = START
at MultipartParser.end (/home/ivan/repositories/luva_acessoria/frontend/node_modules/formidable/lib/multipart_parser.js:326:12)
at IncomingMessage.<anonymous> (/home/ivan/repositories/luva_acessoria/frontend/node_modules/formidable/lib/incoming_form.js:132:30)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1056:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
The text was updated successfully, but these errors were encountered:
I need to simulate a file upload and return the file name.
Only that sometimes it works and sometimes it generates a mistake
dyson.js
upload.ts
error
The text was updated successfully, but these errors were encountered: