Hello,
I am getting the error code 1 when I try to upload an image from gallery.
I already re-install the “file” and “file-transfer” plugin.
if I click in the image URL the imagem show in the Inspector Web.
I am running in the iOS Simulator and in a real device, same error.
The weird part, works perfectly on Android
I am using:
cordova-plugin-file 3.0.0 "File"
cordova-plugin-file-transfer 1.2.1 "File Transfer"
cordova 5.2.0
ionic 1.5.0
[Log] ERROR:
{
"code": 1,
"source": "file:///Users/userName/Library/Developer/CoreSimulator/Devices/C4B69524-8BC5-46B3-BF6F-6364398A4CB6/data/Containers/Data/Application/903726D8-6328-4100-B435-0078776064F2/tmp/cdv_photo_001.jpg",
"target": "http://myserver.com/api/create_post/",
"http_status": null,
"body": null,
"exception": null
}
(services.js, line 266)
services.js:
var options = {
fileKey: "post_pic",
fileName: imageURI.substr(imageURI.lastIndexOf('/')+1),
chunkedMode: false,
mimeType: "image/jpg",
params: {
"text": text,
"channel_id": chId,
"headers": {
'Authorization': credentials.token_type + ' ' + credentials.access_token
}
}
};
return $cordovaFileTransfer.upload("http://myserver.com.br/api/create_post/", imageURI, options, true).then(function(result) {
console.log("New post with picture success");
return JSON.parse(result.response);
}, function(err) {
console.log("ERROR: " + JSON.stringify(err));
console.log( options );
console.log( imageURI );
}, function (progress) {
// constant progress updates
console.log( progress );
});
}
controler.js
$scope.takePicture = function() {
var options = {
quality: 45,
//destinationType: Camera.DestinationType.NATIVE_URI,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
allowEdit: true,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 400,
targetHeight: 400,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false
};
console.log( ">>>>> "+ options.destinationType );
console.log( ">>>>> "+ options.sourceType );
$cordovaCamera.getPicture(options).then(function(imageURI) {
$scope.newPost.picture = imageURI;
console.log("Pic taken: " + $scope.newPost.picture);
$cordovaCamera.cleanup();
}, function(err) {
// error
console.log("Camera ERR: " + err);
});
};