# 上传文件时，PDF 预览而非下载

**URL:** https://meta.discourse.org/t/pdf-onebox-instead-of-download-on-uploaded-files/151995
**Category:** Support
**Tags:** composer
**Created:** [2020 年5 月 19 日 20:50 UTC](https://meta.discourse.org/t/pdf-onebox-instead-of-download-on-uploaded-files/151995 "2020-05-19T20:50:15Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### 作者： ![jord8on](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jord8on/32/166809_2.png) [@jord8on](https://meta.discourse.org/u/jord8on)
#### 发布日期： [2020 年5 月 19 日 20:50 UTC](https://meta.discourse.org/t/pdf-onebox-instead-of-download-on-uploaded-files/151995/1 "2020-05-19T20:50:15Z")

</div>

> [@Oneboxing of PDFs and other attachments](https://meta.discourse.org/t/oneboxing-of-pdfs-and-other-attachments/55972):
>
> Continuing the discussion from [Custom visualization for specific attachment types](https://meta.discourse.org/t/custom-visualization-for-specific-attachment-types/14941/16): Putting this out there as a feature request. I’d love to see the ability to onebox PDFs and other attachments along the lines of google docs oneboxing. Or perhaps even simply a file attachment appearance like you’d get using the file upload, ideally also with the file type and size provided. Right now putting a PDF URL on its own line presents as a raw URL. Very 1990s. As my millenial colleague told me recently,…

根据上述主题 ⬆︎，看来我们上传到主题的 PDF 文件应该被“单框化”（one-boxed）。

我希望拥有类似 [此示例](https://meta.discourse.org/t/oneboxing-of-pdfs-and-other-attachments/55972/6?u=jord8on) 中由 “techAPJ” 展示的功能。但不知何故，当我在撰写主题或帖子时使用文件上传按钮添加 PDF 文件时，我只得到以下内容：

![2020-05-19_14-44-39](https://global.discourse-cdn.com/meta/original/3X/b/f/bfa7633b9fccbea54f5409d6701a086fc9ee383d.png)

随后，当有人点击该链接时，它总是直接下载。我希望它能在一个新窗口中打开。

我之前使用过的一些云应用会附加以下 URL 参数：

`\u0026dl=0`（在新标签页中打开预览）或  
`\u0026dl=1`（下载 PDF）

根据我上面链接的主题，听起来 PDF 文件应该会发生“单框化”，但也许我哪里做错了 🤦‍♂️

---

<div class="post-metadata">

### 作者： ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### 发布日期： [2020 年5 月 19 日 22:50 UTC](https://meta.discourse.org/t/pdf-onebox-instead-of-download-on-uploaded-files/151995/2 "2020-05-19T22:50:15Z")

</div>

单行预览仅适用于外部 PDF 链接，而不适用于直接上传的文件。

例如，外部链接：

> **[fw4.pdf](https://www.irs.gov/pub/irs-pdf/fw4.pdf)**
>
> 203.95 KB

与同一文档但已上传的情况对比：

[fw4.pdf](https://meta.discourse.org/uploads/short-url/oUq8WymzldEnRbxHJGmnK6YeGlj.pdf) (173.5 KB)

---

<div class="post-metadata">

### 作者： ![jord8on](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jord8on/32/166809_2.png) [@jord8on](https://meta.discourse.org/u/jord8on)
#### 发布日期： [2020 年5 月 20 日 00:00 UTC](https://meta.discourse.org/t/pdf-onebox-instead-of-download-on-uploaded-files/151995/3 "2020-05-20T00:00:34Z")

</div>

好的，感谢澄清这一区别。

您是否推荐一个用于托管文件的平台，以便之后可以在 Discourse 中一键嵌入？

---

<div class="post-metadata">

### 作者： ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### 发布日期： [2020 年5 月 20 日 00:20 UTC](https://meta.discourse.org/t/pdf-onebox-instead-of-download-on-uploaded-files/151995/4 "2020-05-20T00:20:31Z")

</div>

几乎任何文件托管服务都可以使用，例如 Dropbox、Google Drive 等，只要您能上传公开可访问的文件即可。

---

<div class="post-metadata">

### 作者： ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### 发布日期： [2020 年6 月 19 日 00:22 UTC](https://meta.discourse.org/t/pdf-onebox-instead-of-download-on-uploaded-files/151995/5 "2020-06-19T00:22:14Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
