feat: Add custom save path
What
This PR adds a feature allowing users to define the output path when taking a photo/snapshot or recording a video. The idea was presented in https://github.com/mrousavy/react-native-vision-camera/issues/893.
Additionally, this PR fixes an issue on Android where the quality parameter for takeSnapshot was mandatory, resulting in an error [EUNSPECIFIED: quality] if not provided. (https://github.com/mrousavy/react-native-vision-camera/issues/2804)
Changes
Added a new parameter "path" to specify the output directory for photos, snapshots, and recorded videos. Updated the relevant functions to handle the custom save path.
Tested on
iPhone 12, iOS 17.4.1 Huawei ELE-L29, Android 12
Related issues
- https://github.com/mrousavy/react-native-vision-camera/issues/893
- https://github.com/mrousavy/react-native-vision-camera/issues/2804
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| react-native-vision-camera | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | May 29, 2024 1:26pm |
Hi! Thank you so much for this contribution, this is good stuff. I have a few code-organization/style concerns which I will think about and get back to you soon.
To share what's going on inside my head;
- I am not a big fan of having one function for getting a path or creating a temp file.
- I think maybe we can get the
pathat high-level using a sync native function, and basically always assume the path is non-null and writable on native side. In the JS func for startRecording/takePhoto/takeSnapshot we get a temp path from native if the current path is null (or not writable). This also reduces the amount of logic/branching on the native side and moves it to JS, where code is more flexible in general -
messageis a bit weird for the error parameter, I'd call itcauseor something and pass an error I guess? Just a minor nitpick
Don't worry about changes right now, I'll get back to you in a few days about this. But I definitely think this should go into main, this is good nice work 👍
Thank you for taking the time to review my PR and for your positive feedback.
I agree that it could be a good idea to have a function for getting a temporary path and managing the path logic directly in the JS code. This would indeed simplify the native side and make the code more flexible overall.
I'll wait for your detailed feedback before making any changes. Looking forward to refining this feature based on your suggestions :)