与React Native共享文件 [英] Share file with React Native

查看:80
本文介绍了与React Native共享文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用"react-native"中的{Share}.我成功共享了消息,没问题.

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

现在,我将动态生成PDF并将其保存在本地.是否可以像共享URL一样共享PDF?我没有找到解决方法.

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.

考虑后,如果无法共享PDF.我有用React Native创建动态HTML文件的想法,然后可以共享HTML文件,但这是同样的问题.没有有关与{Share}共享文件的信息.

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}.

我认为使用'react-native'的{Share}是可行的,因为我在Android上的另一个应用程序中看到了相同的东西.

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

推荐答案

我对React native的共享存在相同的问题.我只是使用了这个库反应本机共享.

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

您可以将url传递到文件系统中的文件,它将正常运行:

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",
            })

这篇关于与React Native共享文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆