Closed
Description
URL
Issue Description
What is missing or inaccurate about the content on this page?
Missing : fileName
Description : path: photo.path generating error as Type 'string | undefined' is not assignable to type 'string'.
Modified Code :
private async readAsBase64(photo: Photo) {
// "hybrid" will detect Cordova or Capacitor
const fileName = new Date().getTime() + '.jpeg';
if (this.platform.is('hybrid')) {
// Read the file into base64 format
const file = await Filesystem.readFile({
path: fileName
});
return file.data;
}
else {
// Fetch the photo, read as a blob, then convert to base64 format
const response = await fetch(photo.webPath!);
const blob = await response.blob();
return await this.convertBlobToBase64(blob) as string;
}
}