Error: MultipartParser.end(): stream ended unexpectedly: state = START #79

See original GitHub issue

I am new to node.js . I have created a node.js server which accepts post requests . I am using phonegap android application to send image on local server.

error: Error: MultipartParser.end(): stream ended unexpectedly: state = START

Snippet of code is as shown below . My form.on(‘end’ … is not getting called and there by my image is not getting uploaded on to the server

app.post(‘/upload’, function(req, res) {

        console.log("Upload Code Hit!")

        var form = new formidable.IncomingForm();
        form.parse(req, function(err, fields, files) {
                        console.log("Upload Code Hit2222!")
                        res.writeHead(200, {'content-type': 'text/plain'});
                        res.write('received upload:\n\n');

                        res.end(util.inspect({fields: fields, files: files}));

                        console.log(" form. parse ends ")
                });
        console.log("33333!")
        form.on('end', function(fields, files) {
                console.log(" form.in(end) hit ")
                /* Temporary location of our uploaded file */
                var temp_path = this.openedFiles[0].path;
                /* The file name of the uploaded file */

                var file_name=this.openedFiles[0].name;
                /* Location where we want to copy the uploaded file */
                var new_location = './uploadedFOlder/';

                fs.copy(temp_path, new_location + file_name, function(err) {
                        if (err) {
                        console.error(err);
                        } else {
                        console.log("success!")
                        }
                        });
                });

                console.log("88888")

return;

});

i got Upload Code Hit! 33333! 88888 Upload Code Hit2222! form. parse ends ie I am not getting the log

console.log(" form.in(end) hit ")

I added a code

form.on(‘error’, function(err) { console.log(‘ERROR!’+ err); res.end(); }); and it shows

ERROR!Error: MultipartParser.end(): stream ended unexpectedly: state = START can some one please help me what i am doing wrong ?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
zyywolfcommented, Apr 20, 2015

i catched the exception too,did u solved,?

2reactions
OrangeDogcommented, Aug 14, 2014

Prove it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

MultipartParser.end(): stream ended unexpectedly
I'm using express-http-proxy as my API proxy and multer as suggested. app.use('/api', upload.any(), proxy('http:// ...
Read more >
Error: MultipartParser.end(): stream ended unexpectedly: state ...
I am new to node.js . I have created a node.js server which accepts post requests . I am using phonegap android application...
Read more >
A brand new website interface for an even better experience!
Error : MultipartParser.end(): stream ended unexpectedly: state = START #79.
Read more >
Hello, has anyone managed to send a file with the HTTP ...
The error message is now: {"code":"BadRequestError","message":"MultipartParser.end(): stream ended unexpectedly: state = START_BOUNDARY"} Do you have any ...
Read more >
IOException: "The multipart stream ended unexpectedly"
The input is processed right away (checks if a dataset already exist, persists new datasets, does some heavy calculation, etc.). When starting ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found