How to preview external files ( pdf, word, ppt etc ) which stored in my firebase storage without downloading it?

huangapple go评论58阅读模式
英文:

How to preview external files ( pdf, word, ppt etc ) which stored in my firebase storage without downloading it?

问题

我和我的团队正在使用React Native和Expo托管工作流来制作一款办公室社交媒体应用,我们决定允许办公室的员工上传他们的文件(PDF,文档,PPT等),并在不下载文件的情况下查看文件内容

我尝试使用第三方库,如react-native-doc-viewer和react-native-file-viewer,但这些库不能在我的应用中使用,因为它们的维护不佳。

我尝试使用Webview来预览文档,但在我的手机上,当我尝试这样做时,文件会下载而不是预览

你能帮我解决这个问题吗 😊?请建议一种在我的Firebase存储中预览文件而不下载文件的方式。

对不起,我的英语不太好 😊。

英文:

me and my team making an social media application for office using react native and expo managed work flow , in which we decided to allow employee of office to upload their files (pdf , doc , ppt etc ) and view the content of the file without downloading it.

I used third party libraries like react-native-doc-viewer , react-native-file-viewer for that but those library cant be used in my app because those libraries are not maintained well.

i tried webview for previewing documents but in my mobile when i tried this file gets download instead of previewing it.

can you help me to solve that problem 😀. Suggest the way to preview files stored in my firebase storage without downloading it.

sorry for my English, i am not good in english 😅.

答案1

得分: 1

从您的Firebase存储中获取文件的URL,并将其附加到Google文档查看器,以在常规WebView中查看,我认为这可能有效:

const googleURL = `https://docs.google.com/gview?url=${fileUrl}`;
    
return <WebView source={{ uri: googleURL }} />;
英文:

Fetch the file URL from your firebase storage and append it to the google document viewer to be viewed in a regular WebView, I think this might work:

  const googleURL= `https://docs.google.com/gview?url=${fileUrl}`;

  return &lt;WebView source={{ uri: googleURL}} /&gt;;

huangapple
  • 本文由 发表于 2023年2月26日 20:02:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/75571837.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定