react-native-camera icon indicating copy to clipboard operation
react-native-camera copied to clipboard

save files in custom directory

Open SychevSP opened this issue 6 years ago • 10 comments

In my application I need to save photos and videos to different directories. I patched react-native-camera to make it possible to specify custom paths to folders. One can construct path to directory with a library such as RN-Fetch-Blob and pass it as an option to takePictureAsync or recordAsync. If the change seems beneficial I am happy to share it with the community.

SychevSP avatar May 04 '19 19:05 SychevSP

This looks really good! Im going to give a try on this with Android. If someone can handle the test on IOS would be great, since i cant test this on the weekend.

MateusAndrade avatar May 04 '19 19:05 MateusAndrade

can't you use this https://github.com/itinance/react-native-fs?

sibelius avatar May 06 '19 11:05 sibelius

If you want to save photos/ videos to a custom directory instead of cacheDir/Camera you can take the path returned by takePictureAsync or recordAsync and then feed this path to another library to move the file.
It can be https://github.com/itinance/react-native-fs or https://github.com/joltup/rn-fetch-blob or any other library that can move files. But it is a two step solution: first take picture, then move it

In my app I wanted to do it in one step. So made this little tweak to react-native-camera.

SychevSP avatar May 06 '19 17:05 SychevSP

I think we can land this

let's add to new docs as well

sibelius avatar Jun 12 '19 21:06 sibelius

I think we can land this

let's add to new docs as well

Would be nice apply this with our new docs using docusaurus. We can even modify READM.MD showing this.

MateusAndrade avatar Jun 13 '19 01:06 MateusAndrade

Does this library currently store data in the documents folder of the app? If not, how would I use this PR to save photos there https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html

zackify avatar Jul 10 '19 20:07 zackify

@zackify could you test if this PR solve your use case?

sibelius avatar Jul 10 '19 20:07 sibelius

What I’m trying to say is that I don’t understand where the temporary photos are currently stored, or if this PR will let me put them in a persistent place.

Basically I need to store photos in my app, but not to the camera roll. But I want them to stay on the phone until the app is deleted

zackify avatar Jul 12 '19 19:07 zackify

@zackify the photos are stored in cache, but as explained above you can use other libraries to save the file to a specific location.

@SychevSP are you still working on this? Or should I fork it and make the required changes?

fabOnReact avatar Mar 11 '20 18:03 fabOnReact

I have a more recent version of this feature which I forked in December. I currently use in one of my projects https://github.com/SychevSP/react-native-camera/commits/save-in-dir

SychevSP avatar Mar 12 '20 07:03 SychevSP