【发布时间】:2016-12-07 14:14:30
【问题描述】:
最近我发现我无法再从我的应用 (iOS) 上传图片和视频。经查,window.resolveLocalFileSystemURL函数总是失败,返回{"code":5}。但是,直到最近它都运行良好,我没有遇到 Android 的这个问题。我的代码如下:
$('#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)); });
}
变量文件类似于 file:///var/mobile/Containers/Data/Application/UID/tmp/cdv_photo_021.jpg
你知道我应该怎么做才能让它工作吗?
【问题讨论】:
-
您是否正在尝试写入您的应用程序目录?如果是这样,我不确定你能做到这一点:cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/…
-
感谢您的评论。实际上它之前运行良好并且根据您提到的页面 /tmp/ 文件夹是可写的。
-
我收到编码区域的时间通常是在尝试写入我无法写入的文件夹时。我建议尝试将文件写入其他地方来测试这个理论
标签: ios cordova cordova-plugin-file cordova-ios resolveurl