parted
parted copied to clipboard
TypeError: Cannot read property 'path' of null
I'm getting this error
TypeError: Cannot read property 'path' of null
at Parser._finish (/mnt/c/Users/cheye/OneDrive/Desktop/Ethiion/parted-master/lib/multipart.js:371:12)
at Parser._parse (/mnt/c/Users/cheye/OneDrive/Desktop/Ethiion/parted-master/lib/multipart.js:178:18)
at Parser.write (/mnt/c/Users/cheye/OneDrive/Desktop/Ethiion/parted-master/lib/multipart.js:80:10)
at IncomingMessage.ondata (_stream_readable.js:693:20)
at IncomingMessage.emit (events.js:197:13)
at IncomingMessage.EventEmitter.emit (domain.js:439:20)
at IncomingMessage.Readable.read (_stream_readable.js:491:10)
at flow (_stream_readable.js:957:34)
at resume_ (_stream_readable.js:938:3)
at processTicksAndRejections (internal/process/next_tick.js:76:17)
Here's my code:
import { multipart as Multipart } from 'parted';
export default async function (req, res, next){
let options = {
limit: 30 * 1024,
diskLimit: 30 * 1024 * 1024
};
const parser = new Multipart(req.headers['content-type'], options);
parser.on('error', function(err) {
console.log(err);
req.destroy();
next(err);
});
parser.on('end', async function() {
res.end();
next();
});
req.pipe(parser);
}
Turns out this is a result of the FormData object being empty, empty forms arent handled properly