我正在尝试使用 iframe 标记嵌入“Office Web Apps Viewer”,以在我的网站上显示电子表格预览。我尝试使用encodeURIComponent对url进行编码,但它显示“我们正在获取您的文件”加载栏,但没有任何反应。提前致谢。
const originalUrl ="https://exampleDomain.amazonaws.com/Folder/Filename.xlsx?algorithm=algorithmName&credential=region&date=date&expires=time&token=encryptedToken&signature=encryptedSignature&headers=example"
const encodedUrl = encodeURIComponent(originalUrl);
const iFrameUrl = `https://view.officeapps.live.com/op/embed.aspx?src=${encodedUrl}`;
<iframe title="l" src={iFrameUrl} style={{ maxHeight: 'auto', maxWidth: 'auto'}} />
注意:上面的代码通过替换 src = 与 google docs 一起使用
我也刚刚遇到这个问题,所以我做了一些挖掘。如果有的话,它似乎会失败GET
URL 中的变量。我突然想到一个想法,即使用 URL 重定向来屏蔽 S3 URL,然后这有效。 (我用了bit.ly https://bit.ly创建一个没有任何重定向GET
变量)
显然,这不是一个出色的解决方案,但它确实有效。如果您拥有该服务器,您可以创建自己的后端来生成这些不包含的 URLGET
变量。
然后您可以生成以下格式的 URL:
https://example.com/api/s3request/s3_domain_path/get_param_1/getparam_2/get_param_3/etc/
这将返回一个重定向到:
https://s3_domain_path?X-Amz-Security-Token=get_param_1&X-Amz-Algorithm=get_param_2
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)