How to set key for file getting uploaded in $cordovaFileTransfer in ngCordova?

The documentation mentions this method to upload a file to a server.

document.addEventListener(‘deviceready’, function () {

$cordovaFileTransfer.upload(server, filePath, options)
  .then(function(result) {
    // Success!
  }, function(err) {
    // Error
  }, function (progress) {
    // constant progress updates
  });

}, false);

});

I want to send the uploaded file as a value for the key ‘closet_image’ in the post data form. How do I do that?

Try this

var options = {fileKey: 'closet_image'};

From docs: https://github.com/apache/cordova-plugin-file-transfer/blob/master/doc/index.md