[Web Previewer] Component does not preview files from S3 bucket except image

Forge Component
(18)
Published on 2018-11-19 by Rui Mendes
18 votes
Published on 2018-11-19 by Rui Mendes

OutSystems installation: On-Premise

Platform version: O 11.0.424.0

File Storage: Amazon S3 

In our On-Premise version of OutSystems I'm consuming the REST API from S3 to get the non-public file URL along with security token, long expiry time and other amazon parameters.

The URL I receive is accessible on browsers, but when supplied to Web Previewer component, it throws error (can not preview the file). 

It works with image (png/jpeg), but not with other types e.g. docx, xlsx, pptx, pdf.

Making the files public it starts showing in the preview panel. This eliminates the thought of Firewall issue.

Also, if browsers can open the non-public file provided the security token then what's causing issue with component? Any pointer?

Solution

Ah, I found the issue and made it work. 

For future readers,





  • Google doc viewer expects below parameters as I read in manual
    • url: document url (encode the url if it containes parameters, etc.)
    • hl: language (ex: en, hn etc.)
    • embedded: embededable link, value true/false [MUST be used true to show]


  • Docs Manual made my day, I encoded the URL in JS function
    encodeURIComponent() encodes a URI component with special characters
    Resulting as encoded URL = https%3A%2F%2Fbucketputswatantra.s3.eu-central-1.amazonaws.com%2F26011983.pdf%3FX-Amz-Expires%3D604800%26X-Amz-Algorithm%3DAWS4-HMAC-SHA256%26X-Amz-Credential%3DAKIAIUKRHHK5GXNGVHDA%2F20190826%2Feu-central-1%2Fs3%2Faws4_request%26X-Amz-Date%3D20190808T133519Z%26X-Amz-SignedHeaders%3Dhost%26X-Amz-Signature%3D466647bb4407d7cf123ee9a2a72057e19218f039f3c2baa5934fd1cd686099da



N.B: I've changed few parameter values to safeguard content.

Solution