0

I am trying to connect to my S3(privately- using access key) and load a document file for display on iframe. However when i add the following html code to my front end, it ends up downloading the file to my computer instead for loading it within the iframe. How do I make it display within the iframe?

<!--index.html.erb-->
<!-- image is the attachment done through paperclip gem-->
<iframe src="<%= @file.image.expiring_url(50)%>" width="100%" height="800" >
Venomoustoad
  • 1,203
  • 1
  • 14
  • 38

1 Answers1

0

<iframe> is not the best way to display files. Use object where you can provide an error message when a file can't be displayed. Browser displaying file inside iframe only when there is installed a required plugin for displaying relevant format, otherwise start downloading. That is not Ruby issue.

Read this stackoverflow post HTML embedded PDF iframe for more information.

Leo
  • 1,673
  • 1
  • 13
  • 15
  • do embed and object tags only work for a specific set of file types. I tried going through the docs to try and get the right type . My files are in various different sub-formats from doc, docx, pdf. http://www.iana.org/assignments/media-types/media-types.xhtml – Venomoustoad Jul 12 '18 at 22:17
  • i am currently consistently getting an error- saying plugin is not supported for some of these formats. It seems to work for simple img/ jpeg formats. – Venomoustoad Jul 12 '18 at 22:18
  • There is no any universal solution to do that in frontend. When you need support multiple formats and be sure that shall be displayed in a page, you must find solution convert that object to HTML format. – Leo Jul 13 '18 at 10:58