0

Google Docs 和 Microsoft Office Live 无法从 Firebase 存储中嵌入/渲染 doc/pdf/ppt 文件。我什至将我的 Firebase 存储规则设置为可公开访问。我还尝试使用 javascript | 嵌入 url encodeURIComponent| encodeUri仍然不能解决我的问题。

//This is the public url of .ppt that I want to display in my html website:

https://firebasestorage.googleapis.com/v0/b/work-from-home-app.appspot.com/o/tasks%2Fwqk5vnsYlySImAbukg5Z%2Ftest.pptx?alt=media&token=0eabee36-844f-47de-b643-6fa7d8841dfe

我尝试了几种方法,如下所示:

    <!-- This one from google docs doesnt work -->
    <iframe src="//docs.google.com/gview?alt=media&embedded=true&url=https://firebasestorage.googleapis.com/v0/b/work-from-home-app.appspot.com/o/tasks%2Fwqk5vnsYlySImAbukg5Z%2Ftest.pptx?alt=media&token=0eabee36-844f-47de-b643-6fa7d8841dfe" style="width:600px; height:500px;" frameborder="0"></iframe>

    <!-- This one from microsoft doesnt work either -->
    <iframe src="https://view.officeapps.live.com/op/embed.aspx?src=https://firebasestorage.googleapis.com/v0/b/work-from-home-app.appspot.com/o/tasks%2Fwqk5vnsYlySImAbukg5Z%2Ftest.pptx?alt=media&token=0eabee36-844f-47de-b643-6fa7d8841dfe" style="width:600px; height:500px;" frameborder="0"></iframe>

可悲的是,以上都不起作用。但是当我尝试从某人的网站嵌入 .ppt 时,它工作正常。

 <!--  This one works!  -->
 <iframe src="//docs.google.com/gview?alt=media&embedded=true&url=http://video.ch9.ms/build/2011/slides/TOOL-532T_Sutter.pptx" style="width:600px; height:500px;" frameborder="0"></iframe>

我猜我的 Firebase 存储有问题?或者根本不可能从firebase渲染/显示文档文件到google docs或microsoft api?

4

1 回答 1

0

我终于解决了!

我最终使用了谷歌文档查看器,我无法弄清楚微软的那个。

它无法读取我的文档的原因是因为我绑定我的 url 的 api 由于某种原因无法正常工作。

>This one doesn't work
https://docs.google.com/gview?alt=media&embedded=true&url=my_url

>Works for me
https://drive.google.com/viewerng/viewer?embedded=true&url=my_url

请注意, 如果您使用 javascript 工作,您需要将您的代码编码url为 an 。encodeURIComponent

于 2021-07-25T00:55:58.107 回答