File writeFile don't save Blob on some Android

Hi guys,

I have a problem with saving blob to my android device via cordova-plugin-file writeFile method. There is no problem in iOS and some Android devices.

async downloadLogbook(vehicle) {
    try {
      const data = await this.logbookProvider.getLogbookPdf(vehicle.id).toPromise()
      const blob = new Blob([data._body], { type: 'application/pdf' })
      const filename = 'logbook.pdf'
      const opt: IWriteOptions = { replace: true }

      await this.file.writeFile(this.file.dataDirectory, filename, blob, opt)
    } catch (err) {
      this.actionCtrl.showError(err)
    }

method writeFile is not returning anything. No err, no Success

Any idea?
Thanks

@MiriK, were you able to find any solution for this issue? I’m facing the same problem on some android devices.

@MiriK try this

1 Like

I have this same issue, base64 PDF converted into blob and the blob is written to filesystem , but the PDF file size is only zero bytes in Samsung and in some other smartphones, it works fine in Lenovo, pls advice in simple words , solution for this problem, the above fix is not undersatanable

Try this one

@casperkotwal did you find solution ? If please help me to create a pdf file from base64 format and save it on mobile…

Waiting your fast reply

Thanks alot @casperkotwal

Your solution works at last …

Anes

@anespa Can you tell me the right procedure, please?

As you said in index.html at /src i just put the polyfill.js file inclusion above the cordova.js file inclusion.

Thats all.