Change the maximum attachment/upload size

:bookmark: This guide explains how to change the maximum attachment upload size for self-hosted Discourse instances.

:person_raising_hand: Required user level: System Admin

The default attachment upload size limit is 10MB

If you are self-hosting Discourse and need to allow uploads larger than 10 MB, follow the steps below.

Changing the upload size

  1. Connect to your server:
  • Use SSH to access your server’s command line interface.
  1. Edit the configuration file:
  • Navigate to the configuration directory and edit the app.yml file:
cd /var/discourse/
nano containers/app.yml
  1. Modify the upload parameters:
  • Look for the section labeled params. Directly below, add your desired upload size with careful attention to formatting:
params:
  ## Which Git revision should this container use? (default: latest)
  version: latest
  ## Maximum upload size (default: 10m)
  upload_size: 20m
  1. Save your changes:
  • Press Ctrl+X to exit, then Y to confirm, and Enter to save the changes.
  1. Rebuild the Discourse instance:
  • Run the following command from the /var/discourse directory:
./launcher rebuild app
  1. Update site settings:
  • Go to /admin/site_settings/category/files in your Discourse dashboard.
  • Adjust the max attachment size kb to 20480 (for 20 MB) or your preferred size.

Last edited by @david 2025-09-29T13:05:48Z

Check documentPerform check on document:
62 个赞

为什么错误消息不正确?这是我的错误消息。

尝试上传一个 10MB 文件时。错误消息不正确。

3 个赞

那是什么类型的文件?您能将其他文件上传到那个网站吗?

有时浏览器在上传过程中会出现问题,导致暂时性问题。请在新的浏览器会话中,再次尝试上传您的文件。

2 个赞

这篇文章很久没有更新了吗?为什么我找不到“upload_size: 20m”???

2 个赞

第一篇文章是 5 天前更新的

指南说你需要添加那一行。所以,在你添加它之前,你找不到它。我在下面的引用中添加了一些格式。这有帮助吗?

9 个赞

这是否也会影响最大图像大小(KB)的设置?

1 个赞

是的,它会影响任何类型的上传。

更具体地说,我认为 upload_size app.yml 设置被提供给 nginx 作为 client_max_body_size,这与两个站点设置描述中提供的参数相同:

最大图片大小 KB 最大图片上传大小。这也必须在 nginx (client_max_body_size)/apache 或代理中进行配置。大于此大小且小于 client_max_body_size 的图片将在上传时调整大小以适应。
最大附件大小 KB 最大附件文件上传大小。这也必须在 nginx (client_max_body_size)/apache 或代理中进行配置。
4 个赞

此设置现在允许直接输入 MB:

image

也许该设置需要重命名,并且上面的文本也需要更新?

除非有什么变化,否则此对 yml 的更改所做的是更改 Discourse 允许的最大大小。也就是说,ux 中可用的最大大小为 10mb。通过更改 nginx 配置文件中的一些内容,可以增加此最大值。

我的意思是,您不再需要在站点设置中输入 kb - 而不是功能发生了变化。

不过,如果站点设置能够直接反映 YML 中的内容,而无需单独设置,那就更好了。

1 个赞

我认为,虽然用户输入允许使用 MB,但该值始终以 KB 为单位保存。

对我来说,设置名称不是给用户的信息,而是用于标识设置的技术术语。它们是不可翻译的,因此使用不同语言的 Discourse 管理员不一定能理解它们。配置 Discourse 对他们来说也应该有效。因此,描述需要足够好。
也许说英语的用户也应该从这个角度出发,忽略设置名称,更专注于描述。这样您就不会因为名称而感到困惑。

1 个赞

但您可能会遇到多站点实例,并且某些站点想要的少于理论最大值。这至少是存在两个设置的原因之一。

1 个赞

我们是否可以改进该设置的描述文本,并在其中链接到此主题?
我认为这样对每个人都会更好。

1 个赞