Trying to upload image with cordova file transfer plugin with following code snippet.
var params = {
token: credentials.token
}
var options = new FileUploadOptions();
options.fileKey = 'round';
options.fileName = 'round.jpg';
options.mimeType = "image/jpeg";
options.headers = {
Connection: "close"
};
options.params = params;
var ft = new FileTransfer();
ft.upload(croppedImageURL, encodeURI(globals.nodeAppBase + 'v1/users/upload-user-picture'), function(){
console.log("Successfully updated Round Image");
}, function (err) {
console.log('There was an error uploading the media. Please try again later. Error: ' , err);
}, options, true);
But i am getting error:
{"code":3,"source":"file:///data/user/0/com.app.package/68-image.jpg","target":"https://api.server.com/v1/users/upload-user-picture","http_status":null,"body":null,"exception":"Chain validation failed"}
I tried till now:
- Add connection params in headers of options:
options.headers = { Connection: "close" };
2.Add true in as last param of Upload Function.
Still getting error as above mentioned.