$cordovaFileTransfer.upload error code 1 on iOS but works on Android

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);
		});
	};

i have same problem…

did you solve this problem?

Same issue here… any solution to this?

Upload works perfectly in android but in ios & ios simulator I’m getting error code 1.

same issue here, any solution for this guys?

Hi,
Same problem here. Were you guys able to find solution for this?

Hi,

I didn’t notice that other people replied my post.
well, I found the solution a long time ago after a long time debugging.

As far I remember, I removed the $cordovaCamera.cleanup(); in the function $cordovaCamera.getPicture(options).then(function(imageURI)

I hope this help

hi i have the same problem but it works for android but not for ios :frowning: