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

Just open the File To download in WebBrowser.

CODE:

WebBrowser.openBrowserAsync(<file url>)

3 Likes

This is my post about your issue. You can test

It not work :confused:

I created this package today that uses Android’s Storage Access Framework. It has very limited features although with a very generic name, basically, you can save a blob of text to any file with any mimetype, maybe you can use it to save Base64 images, I don’t know, never tested it. If it is helpful for you, I’ll get it published to NPM on request.

However, you need to detach to use this. It’s not scary at all. I feel bad saying this at Expo forum because I started in Expo too, but I can’t find anything within React Native ecosystem can do this, so I ended up spending some time detaching (about a day or so finding all other alternative packages), and then this afternoon creating this package.

Hi, I printed the response object, and I can see that URI Path uri " “file:///data/user/0/host.exp.exponent/files/ExperienceData/%2540arturo181991%252FFileViewer/test.pdf”, then I tried to open it with diferents File Explorer Apps, but they told me ‘File damaged- Can’t acces to file - Somethings like that’, and I decided copy file to Downloads Folder manually and after open it again and it works correctly. So I need to find the way to save it into a folder with necessary permissions

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

Unfortunately doesn’t seem to work on iOS :frowning:

1 Like

Yes, I have the same problem

1 Like

do we have any solution for this? if I plug in usb cable to my laptop and on phone popup, select allow for phone storage access, this will enable write access from my app. However without cable, just open my standalone app, the app can’t write any thing to ${FileSystem.documentDirectory}SQLite

Why is it very difficult to save file on expo?
No solution?
No progress for expo team?
No sample both android and ios?
No package?

Not sure if this is what you guys are looking for as the questiono was pretty ambiguous but here’s a gist of my implementation for image caching using FileSystem.downloadAsync and redux.

It gives me Permission denied how to resolve this? am developing for Android @mossypig

I think you probably have to use the Camera permission. I already have that permission for a totally different part of my app that was done before I ever tried this. Try requesting and accepting permission to the camera to save / edit files. @answary_a

Thanks, it worked. @mossypig

MediaLibrary.createAssetAsync() is working for only these format =>
“audio”: “audio”,
“photo”: “photo”,
“video”: “video”,
If you have this format then you can access gallery folder and save it, but if file format is .pdf or xlsx or csv then you can’t,

other solution is you have to open Linking.openURL() , then and download the file which is available in downloaded folder,

this is not proper solution. expo team have to look into this problem to access these type of file

2 Likes

This is a very serious disadvantage of expo. There is no way to access public storage apart from camera roll. I don’t want to start saving pdf and word documents into people’s galleries.

I suggest you upvote this feature request:

https://expo.canny.io/feature-requests/p/expose-native-filesystems

This one might also be relevant:

https://expo.canny.io/feature-requests/p/add-externaldirectory-to-expofilesystem

Thanks. Upvoted both. Hope this feature get’s added soon.

I ejected my app in the meantime as I cannot proceed with expo as is :expressionless:

Does expo use a bounty system? I would gladly put up some money to get this feature rolled in.

1 Like

Not as far as I know, but maybe contact secure@expo.io and see what they say.

Otherwise maybe you can implement it yourself and contribute it back to the project (or pay someone else to do it), but it would be best to co-ordinate with the Expo team.