0

I have this base64 conversion method. It expects file and type as Blob. But I have file path for the pdf file. e.g.: let filePath: string = 'file:///...my.pdf';. So how can I consume below method then?

 getBase64(file: Blob) {
    return new Promise((resolve, reject) => {
      const reader = new FileReader();
      reader.readAsDataURL(file);
      reader.onload = () => resolve(reader.result);
      reader.onerror = error => reject(error);
    });
  }

I have seen this solution. But it expects more than what the dev mentioned.

i.e. new File("/path/to/file");. This is simpley not work. It expects like this File(bits, name [, options]);. But how can I give bits part?

Sampath
  • 63,341
  • 64
  • 307
  • 441

1 Answers1

0

I don't need the above method since native file plugin does the job for me.i.e. it returns the base64 string.

let base64String = await this.file.readAsDataURL(pdfFilePath, pdfFilename)
Sampath
  • 63,341
  • 64
  • 307
  • 441