Cordova resolveLocalFileSystemURL 成功回调在 iOS 上失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21980112/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 23:33:12  来源:igfitidea点击:

Cordova resolveLocalFileSystemURL success call back failing on iOS

ioscordova

提问by greaterKing

I've just created a new project and installed the file and file-transfer api's via CLI. I have already created a working app previously so I know how to use phonegap and have been doing so for a few years now.

我刚刚创建了一个新项目并通过 CLI 安装了文件和文件传输 API。我之前已经创建了一个可以运行的应用程序,所以我知道如何使用 phonegap 并且已经这样做了几年。

Here is the code:

这是代码:

window.resolveLocalFileSystemURL("file:///localhost/var/mobile/Applications/96B4705C-C70D-4340-9A42-HJ1F28355D43/tmp/cdv_photo_015.jpg", function(fileEntry){
        console.log(fileEntry.name);
    }, function(error){
     console.log('about to resolve this files errors');
        console.log(error.code);
    });

Nothing ever gets outputted in the console debugging window ...and yes I have debug installed cause I have console.log() in other parts of my code that show up.

控制台调试窗口中没有任何输出......是的,我已经安装了调试,因为我的代码的其他部分有 console.log() 显示出来。

It seems like there is an issue when passing URL data from navigator.camera.getPicture() to the file API when using window.resolveLocalFileSystemURL()...any ideas anyone. I'm up to date on phonegap api and everything and I have this issue for the past few days now...I can't seem to solve it.

使用 window.resolveLocalFileSystemURL() 将 URL 数据从 navigator.camera.getPicture() 传递到文件 API 时似乎存在问题...任何想法。我是最新的 phonegap api 和所有东西,过去几天我有这个问题......我似乎无法解决它。

***EDIT***

***编辑***

Seems like when you use Camera.DestinationType.FILE_URIas a parameter for navigator.camera.getPicture(). When you choose a picture and the success call back for navigator.camera.getPicture() is triggered, trying to window.resolveLocalFileSystemURL from the URL that getPicture returns just fails. But if you set Camera.DestinationType.NATIVE_URIit at least returns something but it's in a format that can't be used with the file-transfer api exp: assets-library://asset/asset.JPG?id=220BCEAE-F1EA-4A6A-83B2-AB8833A90BF2&ext=JPG

好像当你使用 Camera.DestinationType 时。FILE_URI作为 navigator.camera.getPicture() 的参数。当您选择一张图片并触发 navigator.camera.getPicture() 的成功回调时,尝试从 getPicture 返回的 URL 中的 window.resolveLocalFileSystemURL 失败。但是如果你设置了 Camera.DestinationType。NATIVE_URI它至少返回一些东西,但它的格式不能与文件传输 api exp 一起使用:assets-library://asset/asset.JPG?id=220BCEAE-F1EA-4A6A-83B2-AB8833A90BF2&ext=JPG

采纳答案by greaterKing

Seems like this was a bug in the file api v1.0.0

似乎这是文件 api v1.0.0 中的一个错误

https://issues.apache.org/jira/browse/CB-6116

https://issues.apache.org/jira/browse/CB-6116

Temp solution is there as well.

临时解决方案也在那里。

Seems like "/local/" was causing the issue. Remove it from incoming uri's if it exist and the resolve should work.

似乎“/local/”是导致问题的原因。如果存在,则将其从传入的 uri 中删除,并且解析应该可以工作。