# 附件发送至分类后显示正常但未上传至文件夹

**URL:** <https://meta.discourse.org/t/attachements-of-e-mails-send-to-categories-nicely-shown-but-not-uploaded-to-folder/154525>\
**Category:** Support\
**Created:** [2020年六月11日 13:42 UTC](https://meta.discourse.org/t/attachements-of-e-mails-send-to-categories-nicely-shown-but-not-uploaded-to-folder/154525 "2020-06-11T13:42:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![agit](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/agit/32/449818_2.png) [@agit](https://meta.discourse.org/u/agit)\
**Post date:** [2020年六月11日 13:42 UTC](https://meta.discourse.org/t/attachements-of-e-mails-send-to-categories-nicely-shown-but-not-uploaded-to-folder/154525/1 "2020-06-11T13:42:37Z")

</div>

大家好，  
我的问题是：我发送了一封带附件的邮件到一个关联了分类的邮箱地址。一切看起来都很完美：邮件会出现在主题概览中，文本被精确渲染。你们还能看到附件被漂亮地添加到主题中（PDF 链接直接指向 `../public/uploads/default/original/1X/`，并带有生成的哈希值，例如 `9559e1bdae42ab7b2e6bb406e0093ebc6e2f740e.pdf`；图片则被内联显示并生成了短链接 👍）。但是，如果我点击这些文件，意外发生了：👹 **404 未找到** 💔，而且内联的图片也无法显示。

我进一步排查了一下。日志看起来没什么问题：文本被渲染……等等：

```plaintext
Started POST "/admin/email/handle_mail" for 173.55.78.161 at 2020-06-11 11:53:19 +0000
Processing by Admin::EmailController#handle_mail as */*
  Parameters: {"email"=>"[整个带附件的邮件源（base64 编码）]"}
  Rendering text template
  Rendered text template (Duration: 0.0ms | Allocations: 1)
Completed 200 OK in 6ms (Views: 2.0ms | ActiveRecord: 0.0ms | Allocations: 1399)

```

但文件从未出现在 `../public/uploads/default/original/1X/` 或 `/tmp/` 中 😭。（_所以很明显，主题视图中的链接无法输出这些文件。_）

我完全不知道该如何继续调试这个问题。（_既然 discourse/mail-receiver 已经成功将邮件“推送”到 discourse，我就暂时排除它的问题。_）我已经找到了 [代码位置](https://github.com/discourse/discourse/blob/dc4071dfef8e5bcc151a7e102098b0d70087e0f3/lib/email/receiver.rb#L1044)，按理说文件应该在那里被创建（至少是在 tmp 文件夹中），但它并没有发生（也没有抛出任何错误）。另外值得一提的是，如果通过前端向主题添加附件，一切都能正常工作，文件也会成功保存到 `uploads` 文件夹中 🎯 🤩。

你们有什么建议，告诉我接下来可以从哪里继续排查吗？或者以前是否听说过类似邮件附件丢失的情况？💨
