# Discourse 的文件上传新时代

**URL:** <https://meta.discourse.org/t/a-new-era-for-file-uploads-in-discourse/210469>\
**Category:** Announcements\
**Tags:** new-feature\
**Created:** [2021 年11 月 30 日 03:41 UTC](https://meta.discourse.org/t/a-new-era-for-file-uploads-in-discourse/210469 "2021-11-30T03:41:26Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

作者： ![martin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/martin/32/491371_2.png) [@martin](https://meta.discourse.org/u/martin)\
发布日期： [2021 年12 月 21 日 23:03 UTC](https://meta.discourse.org/t/a-new-era-for-file-uploads-in-discourse/210469/9 "2021-12-21T23:03:23Z")

</div>

![itsgoneitsdone](https://global.discourse-cdn.com/meta/original/3X/a/9/a9280ad994209fdbf016d0320d6a048ae81d761c.gif)

通过这两次提交，jQuery 文件上传器和 resumable.js 不再是 Discourse 核心的一部分：

> <https://github.com/discourse/discourse/pull/15365>
>
> Now that d5e380e5c14ac1d24f1f5f32d082fdbfbd1a15db has been
> committed there is n…othing in the codebase that uses either
> resumable.js or the old backup-uploader component.
> 
> R.I.P resumable.js :skull: 
> 
> \*\*Note: Not sure if we should merge this until the referenced commit has been floating around in the wild for a little bit, otherwise there will need to be 2 reverts instead of 1 if anything goes wrong.\*\*

> <https://github.com/discourse/discourse/pull/15376>
>
> This commit removes jQuery file uploader from Discourse,
> completing the transit…ion to Uppy. The image-uploader
> and UploadMixin components are also removed in this commit
> as they have already been replaced and are the only things
> using jQuery file upload.
> 
> \`\`\`
> .-'~~~\`-.
> .' \`.
> | R I P |
> | jquery |
> | file |
> | upload |
> | |
> \\\\| 2013-2021 |//
> -----------------
> \`\`\`

我已经尽力将我们所知道的所有插件中对此以及我们旧的 `UploadMixin` 的引用全部移除，但可能还有一些我遗漏的或不知道的。别担心，迁移过程很简单。99% 的用例只需将我们的新 `UppyUploadMixin` 作为直接替换即可，只需极少的更改。例如，请看这里：

> <https://github.com/discourse/discourse/blob/dc619d8c38f07e85d399a3e557a90f41116750b6/app/assets/javascripts/discourse/app/components/emoji-uploader.js>

对于另外 1% 的情况，您可以创建 Uppy 的实例并直接挂接到事件。例如，请看这里：

> <https://github.com/discourse/discourse/blob/dc619d8c38f07e85d399a3e557a90f41116750b6/app/assets/javascripts/wizard/components/wizard-field-image.js>

我还将在该主题的 OP 中涵盖插件的更改。距离我们下一次发布还有几周时间，所以如果有人遇到任何问题，请在此处报告。这真是一段疯狂的旅程！🎢

---

_[View the full topic](https://meta.discourse.org/t/a-new-era-for-file-uploads-in-discourse/210469)._
