Reputation: 1465
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:
options.headers = { Connection: "close" };
2.Add true in as last param of Upload Function.
Still getting error as above mentioned.
Upvotes: 1
Views: 1985
Reputation: 97
Set Android SDK Version in config.xml
to 27
worked for me using [email protected]
<preference name="android-targetSdkVersion" value="27" />
Notice, that if you update cordova-android
to >= 7.0.0 you are dropping support for any android versions older than 5.0.0
. See here for more details.
Upvotes: 0
Reputation: 1165
A couple of things come to mind to check:
<access origin="https://api.server.com" />
or similar in config.xml.Upvotes: 0