File writeFile don't save Blob on some Android


#1

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


#2

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


#3

@MiriK try this


#4

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


#5

Try this one


#6

#7

@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


#8

Thanks alot @casperkotwal

Your solution works at last …

Anes


#9

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


#10

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

Thats all.