简体   繁体   English

如何使用 React Native 将 pdf 文件保存到文件系统(ios/android),可以在应用程序外部访问

[英]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. 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环境: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.如果您使用的是 Expo,可能是 Expo 文件系统。 Because it's an expo package, it works really well in testing and will be easy to implement to your project.因为它是 expo package,所以它在测试中工作得非常好,并且很容易在您的项目中实施。 Here are the docs .这是文档

After some research, I found that its easy to work with byte stream instead a base64 string.经过一番研究,我发现它很容易使用字节 stream 而不是 base64 字符串。

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.正如 Finley 上面所建议的,使用 Expo 库、 Expo 文件系统、Expo Media-Library、Expo-Sharing可以一起使用,以将图像保存到可以从外部访问的设备存储中。

In case of IOS, use Expo-Sharing to open sharing options and from there we can save a file to file system.对于 IOS,使用 Expo-Sharing 打开共享选项,然后我们可以将文件保存到文件系统。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何保存应用程序外部用户可以访问的文件,以及如何在应用程序卸载时删除文件? - How to save a file that is accessible to the user outside of the app and also deletes on app uninstall? 无法在使用react-native-pdf的android应用程序中滚动pdf文件 - Unable to scroll pdf file in android app used react-native-pdf 无法将文件保存在android文件系统中 - can't save file in android file system 如何在iOS本机反应中移植iOS索引文件 - How do I port an iOS index file in react native to android 在android和IOS phonegap应用程序中读取pdf文件 - Reading a pdf file in android and IOS phonegap app 如何保存原生日历(Android和iOS)的条目以反应原生? - How to save entry to native calendar (Android & iOS ) in react native? 文件保存意图,例如共享意图Android / iOS react-native - File save intent like share intent Android/iOS react-native 如何将外部 jar 文件添加到本机应用程序中,并将其用作 javascript 文件中的插件,用于 android 和 iOS - How can I add the external jar file into react native application and use as a plugin into the javascript file for both android and iOS 如何在android的app文件夹之外读取文件? - how can i read a file outside the app folder in android? 如何将android应用程序资产文件夹中的文本文件作为文本或pdf文件保存到android手机的本地目录? - How to save a text file present in asset folder of android app to the local directory of android phone as text or pdf file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM