My server is node.js but I am sending out a URL to the PDF hosted on S3. Using Chrome, the PDF downloads automatically even when embedded in a div or iframe. How can I force it to be embedded?
A link to one PDF in my S3 bucket: http://ws902.s3.amazonaws.com/pdf_1367897334399.pdf
-
Code I'm using that works fine when it's a local PDF...
<iframe src="myfile.pdf" width="100%" style="height:20em"></iframe>
or
<div id="pdf"><object data="myfile.pdf" type="application/pdf"></object></div>
The solution was to send file headers with the file to S3. S3 serves the files with the same mime type as it was uploaded. By default this is octet, so I changed it to application/pdf.
Using node.js and knox:
headers: { 'x-amz-acl': 'public-read','Content-Type': 'application/pdf' }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With