为什么我的IOS应用程序拒绝cdvfile://和file:/// links? [英] Why is my IOS app rejecting cdvfile:// and file:/// links?

查看:1928
本文介绍了为什么我的IOS应用程序拒绝cdvfile://和file:/// links?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,显示图像下载到cordova.file.data目录在我的角/离子/ cordova应用程序。

I'm having a problem displaying images downloaded to cordova.file.dataDirectory in my angular/ionic/cordova app.

我使用cordova-plugin-file,我可以下载文件,并使用.toInternalURL()和/或.toURL 。但是角列表视图拒绝它们。我使用WkWebView为Ios,我的代码在Android上正常工作(使用.toInternalURL())。我在配置和meta content-security-policy ...中列出了cdvfile:// *和file:/// *。

I'm using cordova-plugin-file and I'm able to download the files, and extract the URLS using .toInternalURL() and/or .toURL(). However the angular list view is rejecting them. I'm using WkWebView for Ios, and my code is working fine on Android (using .toInternalURL() ). I've whitelisted both cdvfile://* and file:///* in the config and in the meta content-security-policy...

添加屏幕截图
以下是由.toInternalURL()生成的链接的控制台屏幕截图

I've added screenshots Here's the console screenshot for links generated by .toInternalURL()

链接的截图由.toURL()生成:

Here's the screenshot for links generated by .toURL():

以下是使用的安全政策:

Here's the security policy im using:

<meta http-equiv="Content-Security-Policy" content="default-src * data: cdvfile://* content://* file:///*; style-src 'self' 'unsafe-inline' *; script-src 'self' 'unsafe-inline' 'unsafe-eval' *; media-src *">


推荐答案

好吧,结果是我的问题是WKWEBVIEW 。我已经使用它,并没有意识到这是我的问题的根源。

Ok, so it turns out that my problem was WKWEBVIEW. I had been using it and didn't realize it was the source of my issue.

所以要使用src属性中存储的图像路径,不要使用cdvfile: //或file:///。而是创建一个类似下面的路径:

So to use a stored image path in src attribute, don't use cdvfile:// or file:///. Instead create a path that looks like this:

http:// localhost:12344 / Library / NoCloud / ho_tylw7Ygc.jpg

前端 http:// localhost:12344 / Library / NoCloud 到entry.fullPath并且你都设置为指向你的应用程序的dataDirectory。

Prepend "http://localhost:12344/Library/NoCloud" to entry.fullPath and you're all set to point to your app's dataDirectory.

这篇关于为什么我的IOS应用程序拒绝cdvfile://和file:/// links?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆