eclipsesource / tabris-js

Create native mobile apps in JavaScript or TypeScript.
https://tabrisjs.com
BSD 3-Clause "New" or "Revised" License
1.4k stars 172 forks source link

How to save captured images into media store? #2242

Open bezkel opened 1 year ago

bezkel commented 1 year ago

I want to store captured images from the camera on a way, that they where shown in the gallery.

If I use the fs.writeFile like in the snippet fs.jsx it will store it into fs.cacheDir. I know I can change this into fs.filesDir, but I don't find the file. it stores it into: /data/user/0/com.eclipsesource.tabris.js/files/media/test.jpg

Do I have to change the directory name into something special? It should work on ios as well.

cookieguru commented 1 year ago

If you are using tabris-plugin-camera there is a saveToPhotoAlbum option. See also https://github.com/eclipsesource/tabris-js/issues/1630#issuecomment-382318075 This flag is not available on tabris.device.camera

I haven't tested this in recent versions of Android; since Android 11 you won't be able to write to anything other than the app's data directory (the dir you posted above). It will be up to the user's photo app if that app shows up in the list of albums. Google Photos will do this and the user will have to opt-in to cloud backups for that folder.