node-formidable / formidable

The most used, flexible, fast and streaming parser for multipart form data. Supports uploading to serverless environments, AWS S3, Azure, GCP or the filesystem. Used in production.
MIT License
7.05k stars 682 forks source link

Callback never called when parsing Meteor-http-methods request ? #401

Closed hems closed 6 years ago

hems commented 7 years ago

I'm trying to integrate formidable with Meteor-http-methods but the parse callback isn't firing.

I suspect this.request isn't exactly the request formidable is waiting for?

formidable = require('formidable')

HTTP.methods({
  '/myhook': function(data) {
    console.log( "hook called" );
    var form = new formidable.IncomingForm();
    form.parse(this.request, function(error, fields, files) {
      console.log( "parse finished" );
      console.log(arguments);
    });
  }
});
tunnckoCore commented 7 years ago

I suspect this.request isn't exactly the request formidable is waiting for?

Yea, probably. Can you try to add error event handler?

var form = new formidable.IncomingForm()
form.once('error', console.log)
form.parse(this.request, function(error, fields, files) {
    console.log( "parse finished" );
    console.log(arguments);
});

side note: Why you use some shitty shit that even don't have tests and the code is awful? ;d

hems commented 7 years ago

@tunnckoCore are you talking about meteor?

tunnckoCore commented 7 years ago

@hems sorry for my previous comment. No, I'm talking about Meteor-http-methods.

hems commented 7 years ago

@tunnckoCore is just the first thing that came up on my google search and it worked, what would you recommend? i don't mind changing for something better, surely it won't take a long time (( :

hems commented 7 years ago

@tunnckoCore no need to apologize everybody is entitled to exercise their blue monday

tunnckoCore commented 7 years ago

what would you recommend?

Don't know, I can't recommend something, because I'm not meteor user.

Let's focus on https://github.com/felixge/node-formidable/issues/401#issuecomment-272758675

guidouil commented 6 years ago

I had same issue on Meteor Galaxy, the problem is the upload path. This fixed it for me var form = new formidable.IncomingForm({ uploadDir: '/tmp' });

hems commented 6 years ago

nice catch @guidouil !

Unfortunately, i have no means of testing this code anymore but i'll close the issue as @guidouil is reporting to have found the problem