Yes, I tried it before and I was able to do that. And in your case, it’s possible to create a specific folder in the “Pictures” or “DCIM” directories and manage it within your Capacitor ReactJS app.
You can use Capacitor’s Filesystem
API to write images to those directories by specifying the path as Pictures
or DCIM
. Here’s an example for saving in the “Pictures” directory:
JS Code
const saveImage = async (photo) => {
const result = await Filesystem.writeFile({
path: `Pictures/MyApp/${new Date().getTime()}.jpeg`,
data: photo.base64String,
directory: FilesystemDirectory.External,
});
};
For scheduling a task to clear the folder every 70 days, you can use a background task handler or a third-party plugin like cordova-plugin-background-mode
to run a periodic cleanup function.
But make sure to check for the necessary permissions for managing files outside the app’s sandbox.
Thanks