Alternative to fs.createReadStream() on Ionic

i have been trying to upload an image from my Ionic App to Amazon S3.

on the official documentation(, they have given this as an example:

var fs = require('fs');
var zlib = require('zlib');

var body = fs.createReadStream('bigfile').pipe(zlib.createGzip());
var s3obj = new AWS.S3({params: {Bucket: 'myBucket', Key: 'myKey'}});
s3obj.upload({Body: body}).
  on('httpUploadProgress', function(evt) { console.log(evt); }).
  send(function(err, data) { console.log(err, data) });

How can i create a readStream with my Image received from the camera…

var options = {
        quality : 75,
        destinationType : Camera.DestinationType.FILE_URI,
        sourceType : Camera.PictureSourceType.CAMERA,
        //allowEdit : true,
        encodingType: Camera.EncodingType.JPEG,
        targetWidth: 500,
        targetHeight: 500,
        popoverOptions: CameraPopoverOptions,
        saveToPhotoAlbum: false

    $cordovaCamera.getPicture(options).then(function(imageData) {
      // alert(imageData);

After i have the imgURL, how can i create an readStream from that?, i can upload the image to my S3 bucket but only few bytes are sent, what’s the problem?

The problem is that the first code-block is nodejs i think and not plain browser javascript.

if you want to upload you need the cordova-file-transfer plugin

A nice tutorial can be found here:

you should consider the first approach as the simplest one. But please read the others, too ;).

I tried but i am getting an error with code 2, the documentation said that code 2 is for Invalid URL.
Everything i have writtten is fine… do you have any working code of this?