When using my application, users have the option to select and crop images using Ionic Native - Crop. Once they have cropped their image, I will receive the URI of the image, for example:
file:///storage/emulated/0/Android/data/com.myApp/cache/1535369478970-cropped.jpg?1535369482232
To convert this file to a base64 encoded data url, I plan to utilize Ionic's File API, which offers the method readAsDataURL(path, file). However, I'm unsure how to properly extract the path
and file
from the provided URI so that readAsDataURL(path, file)
can be successfully executed.
Additionally, I'm uncertain about the significance of the numbers following the .jpg?1535369482232
in the URI, as well as the file name and directory structure on iOS, as the URI was obtained from testing on an Android Emulator.
P.S. When attempting to call the method with only the path and no file name as the second argument, I encountered the following error:
{"code":13,"message":"input is not a directory"}
How can I effectively achieve the desired outcome for file paths on both iOS and Android platforms?