How can I get on server an uploaded picture (using ngCordova) from Ionic app?


Hi! I use this function to upload an image to a server running node.js and express.

var uploadPhoto = function(imageURI) {
  var server = "";
  var filePath = imageURI;
  var options = {};

  $cordovaFileTransfer.upload(server, filePath, options).then(function (result) {
  }, function (err) {
  }, function(progress) {

First question: What properties should be added to the options object above?
Second question: How can I get the image on the server?'/upload', function(req, res, next) {

  // How can I extract the image from the request (and save it)?
  // I have to mention that: req.body = {};


If you are using express, then use connect-multiparty module. And in your code do something like this (This is example from y app where I upload file to amazon):

In my node controller:

      return res.jsonp(fileObj);
      return res.jsonp(500, err);

And my uploadService

module.exports = {

upload: function(file, name, success, error) {
var path = file.path;
var destFileName = shortId.generate()+’.’+mime.extension(file.type);

if (name) {
  var b = new Buffer(name);
  var s = b.toString('base64');
  destFileName = s+'.'+mime.extension(file.type);

fs.stat(path, function(err, file_info) {
  var bodyStream = fs.createReadStream( path );

  var params = {
    Bucket: bucket,
    ACL: 'public-read',
    Key: destFileName,
    ContentLength : file_info.size,
    Body: bodyStream

  s3.putObject(params, function(err, data) {
    if (err) {
    } else {
        url: util.format('', bucket, destFileName),
        key: destFileName,
        size: file_info.size



I am also using express, is that module the only way of getting the image data?


Never mind for the dumb question after seconds of plugin in the module it was a success thanks !