admin管理员组

文章数量:1315225

I'm trying to use ngx-doc-viewer to display documents stored in Amazon S3 using presigned URLs, but I keep running into issues when trying to preview them via Google Docs Viewer and Office Online.

What I Tried:

I generated a presigned URL from S3 and tested it in the browser.

I passed the encoded presigned URL to ngx-doc-viewer using Google Docs Viewer:

var encodedUrl = encodeURIComponent(presignedUrl);
var iFrameUrl = '=' + encodedUrl + '&embedded=true';

Error: "No Preview Available"

I tried using Microsoft Office Online:

var iFrameUrl = '.aspx?src=' + encodedUrl;

Error: "File is not publicly accessible"

I also tested ngx-doc-viewer's built-in URL viewer option, and instead of previewing the file, it downloads it. This suggests that the file is accessible, but the viewers fail.

I found this blog post discussing the exact same issue. They resolved it by encoding the presigned URL with encodeURIComponent(), but this solution did not work for me.

Questions: Why are Google Docs Viewer and Office Online failing to preview my S3 presigned file, even though the URL is accessible? Has anyone successfully previewed S3 presigned URLs in ngx-doc-viewer using these services? Is there an alternative document viewer that supports private S3 URLs without requiring the file to be fully public? Any insights would be greatly appreciated!

本文标签: