[英]How to save a file that is accessible to the user outside of the app and also deletes on app uninstall?
[英]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. 这个文件应该可以在应用程序之外访问。
环境:React Native,Expo
我可以使用的最好的库是什么。
在线查看了很多资源,但很困惑它们是保存在本地应用程序存储中还是应用程序外部。
如果您使用的是 Expo,可能是 Expo 文件系统。 因为它是 expo package,所以它在测试中工作得非常好,并且很容易在您的项目中实施。 这是文档。
经过一番研究,我发现它很容易使用字节 stream 而不是 base64 字符串。
正如 Finley 上面所建议的,使用 Expo 库、 Expo 文件系统、Expo Media-Library、Expo-Sharing可以一起使用,以将图像保存到可以从外部访问的设备存储中。
对于 IOS,使用 Expo-Sharing 打开共享选项,然后我们可以将文件保存到文件系统。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.