Question

I am trying to do a file upload in Flatiron. Without using Flatiron (only Node), I was able to do a file upload using Formidable like so -

form = formidable.IncomingForm()
form.parse request, (error, fields, files) ->
   # upload done

However the same code does not work in Flatiron. It is hangs there after the first line -

form = formidable.IncomingForm()
app.log.info 'Form object made' # This is getting printed
form.parse @.req, (error, fields, files) ->
    app.log.info 'Upload done' # This is not getting printed

What am I missing here? There is no error as well.

Note - The code samples are in CoffeeScript.

Était-ce utile?

La solution

file uploads with flatiron seems a bit of a mystery. I didn't find much information either. So here is my solution (as sticked together from pieces from the internet).

You have to turn buffer of in union / flatiron.plugins.http.

app.use(flatiron.plugins.http, {buffer: false});

And you have to turn stream on in your post route.

app.router.post('/form', { stream: true }, function (){});

Here is a gist with working code: https://gist.github.com/ichbinadrian/4971260

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top