我从大约一年前升级了这个应用程序,它破坏了cordova文件系统部分。
基本上,我无法再获取resolveLocalFileSystemURL
(之前为resolveLocalFileSystemUR**I**
,但已不再支持)来检索我的照片。它总是在错误回调中结束,错误代码为5或1(取决于前缀,如下所述)
以下是代码,我已经评论了调试警报的相关输出:
function takePicture() {
navigator.camera.getPicture(onPhotoURISuccess, onGetPictureFail,
{ quality: 75, destinationType: Camera.DestinationType.FILE_URI, correctOrientation: true });
return true;
}
function onPhotoURISuccess(imageURI) {
createFileEntry(imageURI);
}
function onGetPictureFail(error) {
fileFail(error);
}
function createFileEntry(imageURI) {
window.resolveLocalFileSystemURL(imageURI, movePhoto, fileFail);
}
function movePhoto(fileEntry) {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
function (fileSys) {
//onsuccess
fileSys.root.getDirectory("FotoscanPhotos", { create: true, exclusive: false }, function (dir) {
//Here dir is as follows:
//isFile: false,
//isDirectory: true,
//name: FotoscanPhotos,
//fullPath: "//FotoscanPhotos/",
//fileSystem: <FileSystem: persistent>,
//nativeURL: "file:///storage/emulated/0/FotoscanPhotos/"
fileEntry.moveTo(dir, (guid + "foto.jpg"), onMoveSuccess, fileFail);
}, fileFail);
}, fileFail);
}
function onMoveSuccess(entry) {
var image = { ean: ean, image: '/' + entry.fullPath, timestamp: convertDateToUTC(), displayTime: displayTime(), size: entry.size };
images.push(image);
Speicher.setImages(images);
}
以下是问题所在:
window.resolveLocalFileSystemURL(localURI, function (fileEntry) {
//localURI comes in as /FotoscanPhotos/filename.jpg though I have also
//tried it with the following prefixes: "file:/" and "file://" and "file:"
}, resolveFileSystemError);
我正在为Android做这个,但没有特定的手机,也不保证使用外部存储(SDCard)。所以我试图在没有使用任何硬编码的情况下做到这一点。
在我看来,相对路径和丢失的存储位置前缀可能存在问题吗?
任何帮助都将非常感谢!
提前致谢
罗
答案 0 :(得分:0)
切换到NativeURL似乎可以解决问题