1

I want to split input stream into 2 stream. Because i am sending 2 image via file upload..

so in my controller i write like this

req.file('image')._files[0].stream

this contains details of 2 image. For example length shows sum of 2 images.

so what i want is soomething like below:

//calculate length of 1st image
var dataLength =0;        
req.file('image')._files[0].stream.on('data', function (chunk) {
    dataLength += chunk;
})
.on('end', function () {  // done
    console.log('The length of 1st was:', dataLength);
});

//calculate length of 2nd image
var dataLength2 =0;        
req.file('image')._files[0].stream.on('data', function (chunk) {
    dataLength2 += chunk;
})
.on('end', function () {  // done
    console.log('The length of 2nd was:', dataLength2);
});

what change should i made? How can i achieve this?

Vishant dhandha
  • 495
  • 7
  • 19

1 Answers1

0

you can use skipper package to handle multi upload

run this command in terminal

npm install skipper --save

at the top of your controller app.use(require('skipper')());

now can use this package

req.file('image').upload({
  // ...any other options here...
}, ...);
Ahmed farag mostafa
  • 2,802
  • 2
  • 14
  • 33
  • I am already using skipper to upload file.. but i want to firstly check the size of both image & then upload the file.. please check out most voted answer of [this](http://stackoverflow.com/questions/25547101/sails-js-checking-stuff-before-uploading-files-to-mongodb-with-skipper-valid-fi). i am using same method. but i cant find solution for multiple files – Vishant dhandha Apr 26 '16 at 13:59