Amazon S3 Signed Url无法与Office Web Apps Viewer一起使用(encodeURIComponent不起作用)

编程入门 行业动态 更新时间:2024-10-19 09:46:15
本文介绍了Amazon S3 Signed Url无法与Office Web Apps Viewer一起使用(encodeURIComponent不起作用)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试将带有iframe标记的"Office Web Apps Viewer"嵌入到我的网站上以显示电子表格预览.我尝试使用encodeURIComponent对URL进行编码,但是显示正在获取文件"加载栏,但没有任何反应.预先感谢.

I am trying to embed 'Office Web Apps Viewer' with iframe tag to show spreadsheet preview on my website. I tried with encodeURIComponent for encoding the url but its showing "we are fetching your file" loading bar but nothing happens. thanks in advance.

const originalUrl ="exampleDomain.amazonaws/Folder/Filename.xlsx?algorithm=algorithmName&credential=region&date=date&expires=time&token=encryptedToken&signature=encryptedSignature&headers=example" const encodedUrl = encodeURIComponent(originalUrl); const iFrameUrl = `view.officeapps.live/op/embed.aspx?src=${encodedUrl}`; <iframe title="l" src={iFrameUrl} style={{ maxHeight: 'auto', maxWidth: 'auto'}} />

注意:上面的代码通过替换src = https:与Google文档一起使用://docs.google/viewer?url=yourUrl&embedded=true

Note: the above code work with google docs by replacing src = docs.google/viewer?url=yourUrl&embedded=true

推荐答案

我也刚刚遇到了这个问题,所以我做了一些挖掘.如果URL中有任何 GET 变量,则似乎失败.关于使用URL重定向来屏蔽S3 URL的想法突然浮出水面,并且这有效.(我使用 bit.ly 创建了没有任何 GET 变量的重定向)

I've just run into this issue also, so I've done some digging. It appears to be failing if there are any GET variables in the URL. An idea jumped to mind about using a URL redirect to mask the S3 URL and this worked. (I used bit.ly to create a redirect without any GET variables)

显然,这不是一个出色的解决方案,但它确实有效.如果您拥有服务器,则可以创建自己的后端来生成这些URL,这些URL不包含 GET 变量.

Obviously, this isn't a brilliant solution but it does work. If you own the server you could create your own backend for generating these URLs that don't contain GET variables.

然后您可以生成以下格式的URL:

You could then generate URLs in the format:

example/api/s3request/s3_domain_path/get_param_1/getparam_2/get_param_3/etc/

哪个将重定向到:

s3_domain_path?X-Amz-Security-Token = get_param_1& X-Amz-Algorithm = get_param_2

更多推荐

Amazon S3 Signed Url无法与Office Web Apps Viewer一起使用(encodeURIComponent不起作用)

本文发布于:2023-11-28 07:03:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641398.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不起作用   Signed   Url   Amazon   Office

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!