我的服务器的node.js,但我发送一个网址到PDF托管在S3。使用Chrome,甚至当嵌入一个div或iframe的PDF自动下载。我怎样才能迫使它被嵌入?
一个链接到我的S3存储桶一个PDF: http://ws902.s3.amazonaws.com/pdf_1367897334399.pdf
-
code我使用的是正常工作时,它是一个本地PDF ...
< IFRAME SRC =myfile.pdfWIDTH =100%的风格=高度:20em>< / IFRAME>
或
< DIV ID =PDF><对象数据=myfile.pdf类型=应用程序/ PDF>< /对象>< / DIV&GT ;
解决方案
解决的办法是发送文件头的文件,以S3。 S3服务的文件具有相同的MIME类型,因为它被上传。默认情况下,这是字节,所以我改成了应用程序/ PDF格式。
使用的Node.js和诺克斯:
标题:{'的X AMZ-ACL:公众阅读,内容类型:应用程序/ PDF'}
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' }
上一篇:在S3上的资源影响其他组的AWS IAM组策略?组策略、资源、IAM、AWS
下一篇:如何添加已经存储在S3上,以carrierwave由同一个数据存储备份文件?数据存储、备份文件、carrierwave