Ionic 5 angular firebase show pdf from storage

Viewed 319

I have problems to show a pdf which I have hosted in firebase storage, the problem is that in my function

 download(url: string, title: string) {
    this.fileTransfer = this.transfer.create();
    this.fileTransfer
      .download(url, this.file.dataDirectory + title + ".pdf")
      .then(entry => {
        console.log("download complete: " + entry.toURL());
        this.fileOpener
          .open(entry.toURL(), "application/pdf")
          .then(() => console.log("File is opened"))
          .catch(e => console.log("Error opening file", e));
      });
  }

I refer to a url and this works for me, but I need to relate that url with an id number so that it only brings me the pdf i need. this is my code en el html

<div class="ion-padding">
  <ion-button fill="outline" expand="block" size="small"
    (click)="
      download(
        'https://firebasestorage.googleapis.com/v0/b/myproject-67ce7.appspot.com/o/ORDEN%20DE%20COMPRA%2014766.pdf,
        'PDF'
      )
    "
    >Ver Documento PDF</ion-button
  >
</div>

but I need the id I need to bring in the url, in this case it is 14766, but I have others and I want to bring it according to those id. Thank you!!

0 Answers
Related