Download image by firebase storage url


#1

I’m developing an app that download images by giving the links.

Eg: http://deportivate.com/wp-content/uploads/revslider/home-demo/sample-image-white.png
if i use link like this it will be downloaded.

But if i used firebase downloadUrl
https://firebasestorage.googleapis.com/v0/b/myapp.appspot.com/o/1.jpg?alt=media&token=ea450d47-b12c-4bcc-9e35-c2aba22bc5

it won’t downloaded.

but if i use the this firebase link directly it shows the picture.

Whats wrong with the url??


#2

It should work. There’s some issue in your code.


#3

I think it is a problem with Photolibrary Pluging.Then I Used transfer plugin.And again it wont downloaded.But in the template its working. So i used this project and rebuild on it.Now everything working.Files are downloading but can’t findout where.

How to set a custom location to download.

downloadImage(image) {

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

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

  const imageLocation = **Any Url Here**;

  fileTransfer.download(imageLocation, this.storageDirectory + 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();

  });

});

}