在浏览器中打开PDF而不是下载它

bpprox22

将PDF上载到媒体档案库后,我试图从站点的页面链接到它。

编辑内容时,我使用超链接工具,然后通过URL输入框选择要链接的PDF。

在此处输入图片说明

保存并发布内容后,单击链接将下载PDF,我看不到任何明显的方法可以通过使用当前Media ID Composite提供的功能在浏览器中使此视图变为可查看状态。渲染后,我们得到以下信息:

<a href="/media/64d5b13e-07f2-402f-9b1a-dcfd75d977da/F-KbnQ/CompositeDocumentation.pdf" target="_blank">pdf</a>

有没有一种方法可以不使用媒体ID而是仅使用文件名来引用PDF?

这是请求/响应头信息: 在此处输入图片说明

在阅读了PauliØsterø所说的内容之后,我理解了问题所在,但仍然无法想到解决方案。

I can get the PDF to view in the browser by adding ?download=false to the href URL via Developer Tools. But when I try to add ?download=false to the href through Composite, it doesn't take affect and I get the console output: "Resource interpreted as Document but transferred with MIME type application/pdf: "http://c1.wittenauers.com/media/4afb7bc8-f703-469d-a9b2-a524d8f93dcb/ryc7iw/CompositeDocumentation.PDF"."

Here is the network trace that was asked for by Pauli. In the image, I included the bit where I add ?download=false to the URL, in source view, just in case there could be another way to add it.

在此处输入图片说明

Edit: URL and headers for the page.

Here is the link to the page that contains the link: http://c1.wittenauers.com/cafe/test

Here is the headers for the page containing the link: 在此处输入图片说明

Pauli Østerø

From what you're experiencing, it seems to me that Composite have gotten the MIME type of your uploaded file wrong, and is therefor not correctly telling the browser that this file is a pdf, and the browser doesn't know what to do with it.

  1. Try deleting the file and uploading it again.
  2. Try add ?download=false and the end of the href to the file. You prob. need to go into source mode of the content editor.

This is the exact line in the Source Code which is responsible for this behavior, and the logic is as follows

  • If there is no Querystring named download, the attachment is determined by the Mime Type. Only png, gif and jpeg will be shown inline, the rest will be shown as attachment.
  • 如果有一个名为download的Querystring的值为false,它将覆盖Mime Type检查,并始终将Content-Disposition强制内联。

我在这里进行了快速测试,以表明该行为是预期的。至少在Windows 8的Chrome浏览器中

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

PDF强制下载,而不是在浏览器中打开

如何在 Django 的浏览器中嵌入 PDF 而不是下载它?

(HTML)下载PDF文件,而不是单击时在浏览器中打开它们

在浏览器中打开CSV文件,而不是下载HTML

pdf在浏览器中打开,但下载后会寻找密码

Flask:强制下载pdf文件以在浏览器中打开

在浏览器中查看pdf文件,而不是下载

我如何让浏览器在新标签页中打开pdf文件,而不仅仅是下载它?

如何使用浏览器的PDF查看器而不是下载打开PDF Blob?

如何指示Chrome浏览器下载PDF而不是在浏览器中预览(预览)?

如何下载PDF文件而不是使用dotnetbrowser在浏览器视图中打开

控制器在浏览器中打开文件,而不是下载文件

如何从Google存储桶中强制下载文件,而不是在浏览器中打开文件?

单击用Okular打开的pdf中的链接会打开Abiword(而不是默认浏览器)

如何设置 csv 文件在浏览器中打开而不是在 Site Ground 帐户上下载

PDF 被扔到浏览器控制台,而不是下载

Spring-在浏览器中显示PDF文件而不是下载

PDF在浏览器中显示为二进制文本,而不是被下载

强制在浏览器中查看S3 PDF而不是下载

文件 csv 未下载,而是在浏览器中打开

正在下载扩展名为 .log 的日志文件,而不是使用 nginx 服务器在浏览器中打开

下载动态生成的图像,而不是在浏览器中显示

文件被下载而不是显示在浏览器中

错误尝试在浏览器中查看PDF文档时,它只是被下载了[ASP.net Core 3.0]

在AngularJS中,如何使用ng-click在iPad浏览器的新选项卡中打开下载pdf

InAppBrowser.open在浏览器而不是WebView中打开

停止在浏览器而不是IDE中打开TFS构建

在浏览器中打开Rmd文件而不是HTML

如何在flask路由中传递url参数(在浏览器中打开时自动下载pdf的url)