Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving a file with react Native

Tags:

react-native

I'm working on an option in my React Native app to take data from a Realm database, convert it into csv, and send it via email. I'm planning to use react-native-mail to send the email with the attachment.

How can I save a text file on the user's device, so I can supply it to the native email app with react-native-mail (or for any other purpose)?

like image 519
amirfl Avatar asked May 30 '16 19:05

amirfl


People also ask

How do I write a file in react native?

Write the content data to it await RNFS. writeFile(filePath, content, "utf8"); console. log("written to file"); } catch (error) { //if the function throws an error, log it out. console.


1 Answers

I haven't tried it out, but have you had a look at: https://github.com/Murriouz/react-native-file-manager? If that doesn't suit your needs, and you cannot find another option out there, your best bet would be to write your own native module. The docs have some details on doing this: http://facebook.github.io/react-native/docs/native-modules-ios.html#content

like image 115
agmcleod Avatar answered Oct 10 '22 12:10

agmcleod