0

Recently I figured out that I could no more upload pictures and videos from my app (iOS). After investigation, the function window.resolveLocalFileSystemURL always fails and returns {"code":5}. However, it worked fine till recently and I do not meet that issue with Android. My code is as follow:

$('#take_picture').click(function(){
    navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 60, destinationType: Camera.DestinationType.FILE_URI, correctOrientation: true, targetHeight: 621, targetWidth: 621 });
});
$('#take_video').click(function(){
    var options = { limit: 1, quality: 0, duration: 10 };
    navigator.device.capture.captureVideo(onCaptureSuccess, onCaptureFail, options);
});

function onCaptureSuccess(mediaFiles) {
    var i, len;
    for (i = 0, len = mediaFiles.length; i < len; i += 1) { movePic(mediaFiles[i].fullPath); }
}

function onPhotoDataSuccess(imageURI) { 
    if (device.platform == 'iOS') { file = file.replace('/private/', 'file:///'); }
    movePic(imageURI);
}
function movePic(file){ 
    window.resolveLocalFileSystemURL(file, resolveOnSuccess, function(data){ alert(JSON.stringify(data)); }); 
} 

The variable file is like file:///var/mobile/Containers/Data/Application/UID/tmp/cdv_photo_021.jpg

Do you know what should I do to make it working?

Pierre
  • 1,044
  • 15
  • 27
  • Are you trying to write to your application directory? If so, i'm not sure you can do that: https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/#ios-file-system-layout – Andrew Berry Dec 07 '16 at 16:34
  • Thanks for your comment. Actually it worked well before and according to the page you mention the /tmp/ folder is writtable. – Pierre Dec 08 '16 at 05:23
  • The times I have received the encoding area is usually when trying to write to a folder I can't write to. I would suggets trying to write the file somewhere else to test this theory – Andrew Berry Dec 08 '16 at 09:19

1 Answers1

-1

Finally, I completely uninstalled/re-installed Phonegap, updated Cordova-ios and now this problem is solved, even without modifying any line of code.

Pierre
  • 1,044
  • 15
  • 27