简体   繁体   中英

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.

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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM