小编bam*_*asz的帖子

使用Ionic 3将文件保存到Downloads目录

我知道此链接:https : //cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/#where-to-store-files

但我想将文件保存在下载目录中。是否可以使用Ionic将文件保存在任何路径中?如果是这样,请分享示例。

这是代码:

downloadImage(image) {

this.platform.ready().then(() => {

  const fileTransfer: TransferObject = this.transfer.create();

  const imageLocation = `${cordova.file.applicationDirectory}www/assets/img/${image}`;

  fileTransfer.download(imageLocation, cordova.file.externalDataDirectory + image).then((entry) => {

    const alertSuccess = this.alertCtrl.create({
      title: `Download Succeeded!`,
      subTitle: `${image} was successfully downloaded to: ${entry.toURL()}`,
      buttons: ['Ok']
    });

    alertSuccess.present();

  }, (error) => {

    const alertFailure = this.alertCtrl.create({
      title: `Download Failed!`,
      subTitle: `${image} was not successfully downloaded. Error code: ${error.code}`,
      buttons: ['Ok']
    });

    alertFailure.present();

  });

});

}
Run Code Online (Sandbox Code Playgroud)

基本上,我想将文件保存在用户可见的位置。

android cordova ionic-framework ionic3

6
推荐指数
2
解决办法
1万
查看次数

我有 npm 包的 repo 的分支。我应该如何使用它?

所以有这个原始 npm 包的 repo:https : //github.com/twinssbc/Ionic2-Calendar

我想在我的项目中使用它的 fork,它不作为 npm 包存在:https : //github.com/twinssbc/Ionic2-Calendar/tree/24feacfb29102ec61d6814281867e356fb1a9ee0

我希望能够在我的 Ionic3 项目中使用这个 fork,因为我使用原始包。我如何实现这一目标?我应该用 fork 创建我自己的 npm 包还是有一些更简单的方法?

git npm ionic-framework angular

0
推荐指数
1
解决办法
1882
查看次数

标签 统计

ionic-framework ×2

android ×1

angular ×1

cordova ×1

git ×1

ionic3 ×1

npm ×1