gpt4 book ai didi

ionic4 - cdvphotolibrary : display on IONIC 4

转载 作者:行者123 更新时间:2023-12-04 17:33:50 25 4
gpt4 key购买 nike

有没有办法在 Ionic 4 中显示 cdvphotolibrary://?

我已经尝试了大部分可用的方法来显示缩略图:

<allow-intent href="cdvphotolibrary:*" />
<allow-navigation href="cdvphotolibrary://*" />
<meta http-equiv="Content-Security-Policy" content="cdvphotolibrary:">

想法是显示这样的内容,缩略图实际上是图片库返回的:

cdvphotolibrary://thumbnail?photoId=43%3B%2Fstorage%2Femulated%2F0%2FDCIM%2FCamera%2F20190304_204426.jpg&width=512&height=384&quality=0.8

我正在使用 https://www.npmjs.com/package/cordova-plugin-photo-library

谢谢

最佳答案

好的,错误代码已经提供了更多信息。

It seems cdvphotolibrary:// 协议(protocol)被归类为 file:// 协议(protocol),您不能将它们用于较新的 webview。

但是,对于 file://协议(protocol)有一个解决方法:

这是:

For Cordova apps, the Ionic Web View plugin provides a utility function for converting File URIs: window.Ionic.WebView.convertFileSrc(). There is also a corresponding Ionic Native plugin: @ionic-native/ionic-webview.

而且似乎 file://urls are actually available通过插件:

    this.photoLibrary
.requestAuthorization()
.then(() => {
this.photoLibrary
.getLibrary()
.subscribe({
next: library => {
library.forEach(libraryItem => {
let url: string;
if (libraryItem.id.split(';').length > 0) {
url = 'file://' + libraryItem.id.split(';')[1];
}
// Get http://localhost url
url = (window as any).Ionic.WebView.convertFileSrc(url)
});
},
error: err => {
console.log('could not get photos');
},
complete: () => {
console.log('done getting photos');
console.log(this.images);
count = 0;
},
});
})
.catch(err => {
console.log("permissions weren't granted");
});

然而,似乎 Ionic 可能需要做一些额外的调整 - 查看该线程以了解进一步的讨论。

关于ionic4 - cdvphotolibrary : display on IONIC 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57489377/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com