Share file with React Native

让人想犯罪 __ 提交于 2019-12-22 04:00:41

问题


I use { Share } from 'react-native'. I shared message successfully, no problem.

Now, I generate dynamically a PDF and save it at local. Is it possible to share the PDF like when I share an url? I didn't find solutions.

After thinking, if PDF isn't possible to share. I have the idea to create dynamically HTML file with react native, then I can share the html file, but it's the same problem. There are no informations about sharing file with { Share}.

I think it's possible with the { Share } from 'react-native' because I saw the same thing on another app on Android.


回答1:


I had the same problem with the share of react native. I just used this library React Native Share.

And you can pass the url to the file in your file system and it will work properly:

 Share.open({
                title: "This is my report ",
                message: "Message:",
                url: "file:///storage/emulated/0/demo/test.pdf",
                subject: "Report",
            })


来源:https://stackoverflow.com/questions/45608649/share-file-with-react-native

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!