srd
srd

Reputation: 66

How to save a pdf file to file system (ios/android) with react native which can be accessible outside the app

I am receiving the pdf as base64 encoded string from an api and I want to convert this base64 string to pdf and save it in file system of the device. And this file should be accessible outside the app.

Environment : React Native, Expo

What it the best library that I can use.

Looked at lots of resources online, but confused whether they save in local app storage or outside the app.

Upvotes: 1

Views: 1236

Answers (2)

srd
srd

Reputation: 66

After some research, I found that its easy to work with byte stream instead a base64 string.

And as Finley suggested above, using Expo libraries, Expo File-System, Expo Media-Library, Expo-Sharing can be used together to save the image to device storage which can be accessed from outside app.

In case of IOS, use Expo-Sharing to open sharing options and from there we can save a file to file system.

Upvotes: 0

Finley
Finley

Reputation: 176

If you're using Expo, probably Expo FileSystem. Because it's an expo package, it works really well in testing and will be easy to implement to your project. Here are the docs.

Upvotes: 2

Related Questions