mercredi 25 février 2015

How to create an multipart/form-data request in node.js

I'm wondering how to create an multipart/form-data request with an image from the backend in node.js. I tried with module node-form-data http://ift.tt/QNwn4P but it doesn't work for me and I don't know why. Here's my code:



var form = new FormData();
form.append('upload', fs.createReadStream('logo.jpg'));
http.post(addr, form, headers)


http.post is my own module that sends form in json to addr with headers and it works with normally constructed JSON's but not with FormData.


Aucun commentaire:

Enregistrer un commentaire