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?