How to save the file to device's folder like download

I have found a solution to this! It is not a great solution, and it is a total hack but I just tested it and it works great without needing any extra packages or permissions.

I was struggling to find a way to get a file out of my expo app and onto the device in a way I could edit it. I was trying to export a .txt backup file for my app. Here is how you do it.

React Native has a Camera Roll, it lets you take a photo and move it into the camera storage. However I just tested and it works with any file.

import { CameraRoll } from 'react-native';
...
CameraRoll.saveToCameraRoll( fileURI, 'photo');

This moves the file into the root DCIM directory. Which means it is accessible via USB, or file explorer. It is a straight up hack and probably an oversight on someones part to not check mimetype, but its working!

5 Likes