【问题标题】:Download pdf file from firebase storage ioinc 5从 Firebase 存储 ionic 5 下载 pdf 文件
【发布时间】:2021-07-15 09:31:42
【问题描述】:

我正在尝试在 ionic 5 应用程序中下载 pdf 文件,该文件存储在 firebase 存储中

file:///data/user/0/io.ionic.starter/files/test.pdf

这里是下载功能

download(downloadUrl: string) {
  console.log(downloadUrl);

   this.fileTransfer.download(downloadUrl,this.file.dataDirectory +'test.pdf').then((entry) => {
    console.log('download complete: ' + entry.toURL());

    }, (error) => {
  
    });
    
  }

【问题讨论】:

  • "寻求调试帮助的问题('为什么这段代码不工作?')必须包括期望的行为、特定问题或错误必要的最短代码 在问题本身。没有明确的问题陈述的问题对其他读者没有用处。请参阅:@ 987654321@"

标签: ionic-framework firebase-realtime-database firebase-storage ionic5


【解决方案1】:

你需要添加

android:requestLegacyExternalStorage="true"

AndroidMenifest.xml > application 标签内,如下图所示。需要在android 11版本中添加。

【讨论】:

  • 创建 android 平台后,我在 android/app/src androidmenifest.xml 中添加了 android:requestLegacyExternalStorage="true",即使在添加了同一行 file:///data/user/0/io 之后也是如此。 ionic.starter/files/test.pdf 返回
  • 这里函数下载(downloadUrl: string) { console.log(downloadUrl); this.fileTransfer.download(downloadUrl,this.file.dataDirectory +'test.pdf').then((entry) => { console.log('download complete: ' + entry.toURL()); }, (error ) => { }); }
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-04-01
  • 2021-04-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-08-20
  • 2019-12-10
相关资源
最近更新 更多