I want to save a image locally, maybe in Documents or Gallery. But How can I do that?
Here is my code:
const canvas = await html2canvas(
document.querySelector("#beautifulImage") as any
)
const res = await Filesystem.writeFile({
path: `myImage.png`,
data: canvas.toDataURL(),
directory: Directory.Documents,
})
However, it comes error and say: directory is not created!!!
Finally, I found this works: addandroid:requestLegacyExternalStorage="true" in the application tag in the AndroidManifest.xml, however, the document said, it won’t work on android 11 or newer???
I’m having the same issue. After Android 9 the file security policies have changed. I have not been able to save photos to the gallery as Ionic PWA so far. Would love to hear how others do it. We’ve tried the demo/documentation that Ionic as examples but they do not work. Tested on Android 11 phones so far
We are updating the filesystem plugin to work with Android 12+, but in the meantime adding android:requestLegacyExternalStorage="true" to your AndroidManfest.xml should work for most devices.