Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Amazon S3签名Url无法与Office Web Apps Viewer配合使用(encodeURIComponent无法工作)_Javascript_Amazon S3_Office365_Ms Office - Fatal编程技术网

Javascript Amazon S3签名Url无法与Office Web Apps Viewer配合使用(encodeURIComponent无法工作)

Javascript Amazon S3签名Url无法与Office Web Apps Viewer配合使用(encodeURIComponent无法工作),javascript,amazon-s3,office365,ms-office,Javascript,Amazon S3,Office365,Ms Office,我正在尝试嵌入带有iframe标记的“Office Web Apps Viewer”,以在我的网站上显示电子表格预览。我尝试使用encodeURIComponent对url进行编码,但它显示“我们正在获取您的文件”加载栏,但什么也没有发生。提前谢谢 const originalUrl ="https://exampleDomain.amazonaws.com/Folder/Filename.xlsx?algorithm=algorithmName&credential=region&am

我正在尝试嵌入带有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'}} />
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);
常量iFrameUrl=`https://view.officeapps.live.com/op/embed.aspx?src=${encodedUrl}`;

注意:上面的代码通过替换src=

与google文档一起工作,我也遇到了这个问题,所以我做了一些挖掘。如果URL中存在任何
GET
变量,则它似乎失败。我突然想到了一个想法,即使用URL重定向来屏蔽S3 URL,这很有效。(我以前创建重定向时没有任何
GET
变量)

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

然后,您可以按以下格式生成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

您是否检查了浏览器控制台以查看是否有任何内容,有吗?您是否检查了S3存储桶日志,以查看是否正在尝试访问,但参数已损坏?我们也面临此问题。已签名的s3 URL不起作用。有人有解决方案吗?我也有同样的问题,但使用谷歌云存储。我相信OfficeWebApps浏览器可以简单地处理URL。你救了我一天。谢谢!