Ngcordova fileupload camera ios error code 1


#1

I have a problem with ios and ngcordova fileupload. Somehow i get an error code 1 in ios but i dont know why.

This is where i retrieve the image from camera

$scope.getPictureFromCamera = function(){
var options = {
quality: 50,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: false,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 1000,
targetHeight: 1000,
correctOrientation: true,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: true
};

  $cordovaCamera.getPicture(options).then(function(imageURI){
  	$scope.displayURL = "data:image/jpeg;base64," + imageURI;
  	$scope.pictureURL = "data:image/jpeg;base64," + imageURI;
  },
  function(error){
  	console.log(error);
  });

}

This is where i upload the image to my server

createPostWithPicture: function(post, pictureURI){

  	var url = domain+'/api/v1/statuses/create';
  	var filePath = pictureURI;
  	var options = {
  		"fileKey": "sphoto",
  		"mimeType": "image/jpeg",
  		"params": post
  	}
  	return $cordovaFileTransfer.upload(url, filePath, options);
  },

In Android everything is working fine. In IOS i get an error with the following message:

FileTransferError { code = 1; source = data:image/jpeg;base64,…

I really cant find any solution to this. Help would be awesome!


#2

Generally error code 1 is file not found exception

You should try other option with destinationType

Camera.DestinationType.DATA_URL // Return image as base64-encoded string
Camera.DestinationType.FILE_URI // Return image file URI
Camera.DestinationType.NATIVE_URI // Return image native URI (e.g., assets-library:// on iOS or content:// on Android)


#3

See if this helps.