What's the difference between readAsStringAsync() and writeAsStringAsync() FileSystem in expo?

Viewed 84

I have a function that generates a PDF file and i want to get the Uri's of the file to stoke it locally and then send it as an attachment with MailComposer. I want to know what's the difference between readAsStringAsync() and writeAsStringAsync() in FileSystem?

2 Answers

Both readAsStringAsync() and writeAsStringAsync() are functions of Expo FileSystem.

But the difference is readAsStringAsync() used to read a local files of the device. While writeAsStringAsync() is used to write onto a local file or create a file (if the named file does not exist on the location)

According to Expo Documentation documentation
FileSystem.writeAsStringAsync: "Write the entire contents of a file as a string."

FileSystem.readAsStringAsync: "Read the entire contents of a file as a string. Binary will be returned in raw format, you will need to append data:image/png;base64, to use it as Base64."

Related