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

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

问题描述

我有显示在我的角度/离子/科尔多瓦的应用程序下载到cordova.file.dataDirectory图像的问题。

我使用的科尔多瓦 - 插件文件和我能够下载的文件,并提取使用.toInternalURL()和/或.toURL()的URL。然而,角列表视图拒绝他们。我使用WkWebView对于iOS,我的code是在Android上工作正常(使用.toInternalURL())。我已经列入白名单两种cdvfile:// *和file:/// *在配置和元内容安全策略...

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

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

下面是一个使用安全策略IM:

 < META HTTP-EQUIV =内容安全性政策的内容=默认-SRC *数据:cdvfile:// *内容:// *的file:/// *;风格-src的'自我''不安全的内联'*;脚本的src'自我''不安全的内联'不安全-EVAL'*;媒体SRC *>


解决方案

好了,事实证明,我的问题是WKWEBVIEW。使用它并没有意识到这是我的问题的根源我一直

所以要使用src属性存储的图像路径​​,不要使用cdvfile://或file:///。相反,创建一个看起来像这样的路径:

的http://本地主机:12344 /库/ NoCloud / ho_tylw7Ygc.jpg

prePEND的http://本地主机:12344 /库/ NoCloud 门槛。完整路径和你都设置为指向您的应用程序的DataDirectory目录。

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

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...

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

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 *">

解决方案

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.

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

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

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

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