javascript - busboy won't receive uploaded files -
my form simple. uses ng-flow handle file uploads:
<form class="form-horizontal" enctype="multipart/form-data"> <div flow-init="{target: '/test', testchunks: false, query: {'_csrf': '{{csrf}}', 'somestring': 'teststring'} }" flow-files-submitted="data.flow.upload()" flow-name="data.flow"> <input type="file" flow-btn/> </div> </form>
once image selected, ng-flow
post target route. seems image sent since request payload has bunch of things like:
1048576 ------webkitformboundaryw2yag9m602icpd0q content-disposition: form-data; name="flowcurrentchunksize"
the image isn't big (~1mb)
on nodejs side (with express):
var busboy = require('connect-busboy')({ limits: { filesize: 10 * 1024 * 1024 } }); router.post('/test', busboy, function(req, res) { console.log('test called'); console.log(req.busboy); if (req.busboy) { req.busboy.on('file', function(fieldname, file, filename, encoding, mimetype) { console.log("this fieldname: " + fieldname); }); req.busboy.on('field', function(fieldname, val, fieldnametruncated, valtruncated) { console.log('field [' + fieldname + ']: value: ' + inspect(val)); }); } res.json(); });
req.busboy
returns object full of things, req.busboy.on('file'...
, req.busboy.on('field'...)
never trigger.
why isn't busboy seeing strings , images?
you need pipe request busboy can parse form:
req.pipe(req.busboy);
Comments
Post a Comment