I try to display a .doc file stored on a S3 bucket inside an iframe thanks to google doc viewer api.
I already did some research and found this, which i tried to app
Check the solution specifically for Amazon s3 signed urls. Basically its for viewing private documentation using Google Docs Viewer
Google Docs Viewer with Amazon S3 Private Documents and Presigned URLs
The Amazon S3 Presigned URL contains query string parameters, so it contains "?" and "&" which confuses the outer URL.
So you have to Encode the S3 Presigned URL before passing it to the Google Doc Viewer.
Like this:
var encodedUrl = encodeURIComponent(presigned_url);
var iFrameUrl = 'https://docs.google.com/gview?url=' + encodedUrl;
OR (using S3 .NET Core API)
using (AmazonS3Client S3Client = new AmazonS3Client(accKey, secKey, new AmazonS3Config() { ServiceURL = serviceUrl }))
{
GetPreSignedUrlRequest getPreSignedUrl = new GetPreSignedUrlRequest
{
BucketName = s3BucketName,
Key = fileName,
Expires = DateTime.Now.AddMinutes(30)
};
encoded_SignedUrl = WebUtility.UrlEncode(S3Client.GetPreSignedURL(getPreSignedUrl));
}