Feature(s) impacted
Previewing large PDF file (I my case 1,7MB)
Observed behavior
I tried 2 approaches:
A) Send file as data-url:
And I get this result:
B) Send the S3 signed-URL to the file
And I get the following error (net::ERR_BLOCKED_BY_ORB
) in the browser:
Here are my bucket CORS:
When I copy/paste the URL and request it from another tab in the browser (or CURL it) I get the file without issues.
Expected behavior
Having the PDF displayed
Context
- Project name: Finance X
- Team name: Operations
- Environment name: Development
- Agent technology: rails
- Agent (forest package) name & version: forest_liana (9.3.16)
- Database type: postgresql
Hello @jbescoyez
We only support preview for files with a maximum size of 1.5 Mo
I will add this to the documentation
What is the reason?
If the file is downloaded from S3, it does not impact performance or bandwidth.
Update:
I have tested the second approach (with S3 URLs) in Safari and it works in the file viewer for files > 1.5MB.
The remaining question is: “why does Chrome blocks access to S3 signed URLs”. I am unable to find an answer on the web.
I managed to solve the issue. Here is the full story:
- The S3 signed URLs do not mention the extension of the file type (only the object id)
- The file preview widget choose the HTML tag for the embedded content depending on the filename.
- By default, the file preview widget would choose the
<img>
tag
- Firefox and Chrome block the content of the file when the browser try to display a PDF in an
<img>
tag. (ERR_BLOCKED_BY_ORB
for Chrome and NS_BINDING_ABORTED
for Firefox)
I mitigated this behavior by using ActiveStorage redirect mode for serving files instead of a direct link to S3.
This would be useful to mention in the documentation that the extension of the file in the URL has to match the file type.