将带有图像的angular度file upload请求传递到node.js中的Azure

我几乎有这个工作。 我使用angular-file-upload( http://nervgh.github.io/pages/angular-file-upload/examples/image-preview/ )将file upload到nodejs服务器,然后将其传递给Azure。

router.post('/storeimg', function (req, res, next) { //create write stream for blob var blobSvc = azure.createBlobService(); blobSvc.createContainerIfNotExists('images', function (error, result, response) { if (!error) { // Container exists and allows // anonymous read access to blob // content and metadata within this container var stream = blobSvc.createWriteStreamToBlockBlob( 'images', 'test.png'); //pipe req to Azure BLOB write stream req.pipe(stream); req.on('error', function (error) { //KO - handle piping errors console.log('error: ' + error); }); req.once('end', function () { //OK console.log('all ok'); }); } }); }); 

我遇到的问题是,Azure上生成的文件会附带以下内容

 -----------------------------7df240321a0e9a Content-Disposition: form-data; name="file"; filename="010218_osn.jpg" Content-Type: image/jpeg 

这似乎我也最终在pipe道请求的标题。 我如何避免这种情况? 有没有办法跳过标题?

更新:解决scheme

 var Busboy = require('busboy'); 

 router.post('/storeimg', function (req, res, next) { //create write stream for blob var blobSvc = azure.createBlobService(); blobSvc.createContainerIfNotExists('images', function (error, result, response) { if (!error) { // Container exists and allows // anonymous read access to blob // content and metadata within this container var busboy = new Busboy({ headers: req.headers }); busboy.on('file', function (fieldname, file, filename, encoding, mimetype) { var stream = blobSvc.createWriteStreamToBlockBlob( 'images', filename); //pipe req to Azure BLOB write stream file.pipe(stream); }); busboy.on('finish', function () { res.writeHead(200, { 'Connection': 'close' }); res.end("That's all folks!"); }); req.pipe(busboy); req.on('error', function (error) { //KO - handle piping errors console.log('error: ' + error); }); req.once('end', function () { //OK console.log('all ok'); }); } }); });