# Private Message Attachment Issue

**URL:** https://meta.discourse.org/t/private-message-attachment-issue/29447
**Category:** Bug
**Created:** [May 30, 2015, 10:12am UTC](https://meta.discourse.org/t/private-message-attachment-issue/29447 "2015-05-30T10:12:15Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![dbm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dbm/32/86954_2.png) [@dbm](https://meta.discourse.org/u/dbm)
#### Post date: [May 30, 2015, 10:12am UTC](https://meta.discourse.org/t/private-message-attachment-issue/29447/1 "2015-05-30T10:12:15Z")

</div>

I’m not sure is it global, but recently i’ve tried to attach an file in private message and send to one of the people on my discussion. Seems like Attachment is not working there. If anyone could confirm this problem i would appreciate so we can get fix for it. Thanks 😉

 ![](https://global.discourse-cdn.com/meta/original/3X/c/7/c76e349c93c637854dd15de097295615e350eb5b.png)

---

<div class="post-metadata">

### Author: ![Michael\_Hrenka](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/michael_hrenka/32/42499_2.png) [@Michael\_Hrenka](https://meta.discourse.org/u/Michael_Hrenka)
#### Post date: [May 30, 2015, 10:16am UTC](https://meta.discourse.org/t/private-message-attachment-issue/29447/2 "2015-05-30T10:16:20Z")

</div>

Yes, I’ve just run into the same problem. A user sent me a .docx file per private message and the link was broken. However, the file was uploaded successfully and I used SFTP to download and read it.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 30, 2015, 7:55pm UTC](https://meta.discourse.org/t/private-message-attachment-issue/29447/3 "2015-05-30T19:55:07Z")

</div>

@techapj can you look into this? Possibly related to recent upload changes, perhaps..

---

<div class="post-metadata">

### Author: ![adundovi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/adundovi/32/42645_2.png) [@adundovi](https://meta.discourse.org/u/adundovi)
#### Post date: [May 31, 2015, 10:25am UTC](https://meta.discourse.org/t/private-message-attachment-issue/29447/4 "2015-05-31T10:25:08Z")

</div>

I can confirm this. Every new upload on my installation is affected after rebuilding container 10 hours ago.

I suppose that the problem is in a new path “/uploads/default/original/ **2X** /…/hash”? Where is this 2X coming from? I had done “rake uploads:migrate\_to\_new\_pattern” but it didn’t help.

EDIT: OK, I see from the routes.rb there is a new upload pattern (dir1/dir2) where every uploaded file is moved (`/var/www/discourse/config/routes.rb`):

```
get "uploads/:site/original/:dir1/:dir2/:sha.:extension"

```

Files do exist locally (/shared/uploads/default/original/2X) but Discourse is not routing it right.

EDIT2: I’ve temporarily fixed it by changing the route constraints `dir1: /[a-z0-9]/` to `dir1: /[a-zA-Z0-9]+/`:

```
get "uploads/:site/original/:dir1/:dir2/:sha.:extension" => "uploads#show", constraints: { site: /\w+/, dir1: /[a-zA-Z0-9]+/, dir2: /[a-f0-9]/, sha: /[a-f0-9]{40}/, extension: /\w{2,}/ }

```

because “X2” cannot be matched with the default regexp setting. Hope to see the official fix soon 😉

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 31, 2015, 11:40am UTC](https://meta.discourse.org/t/private-message-attachment-issue/29447/5 "2015-05-31T11:40:00Z")

</div>

Yeah @zogstrip and @sam this should be looked into.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [May 31, 2015, 9:26pm UTC](https://meta.discourse.org/t/private-message-attachment-issue/29447/6 "2015-05-31T21:26:13Z")

</div>

Thanks @dbm for reporting that issue and @adundovi for looking into it. I just pushed a fix 🐇

[https://github.com/discourse/discourse/commit/73b8cfa7d7dbbb154a65e57505da47e4a618c668](https://github.com/discourse/discourse/commit/73b8cfa7d7dbbb154a65e57505da47e4a618c668)

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [May 31, 2015, 9:26pm UTC](https://meta.discourse.org/t/private-message-attachment-issue/29447/7 "2015-05-31T21:26:16Z")

</div>



---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 31, 2015, 9:57pm UTC](https://meta.discourse.org/t/private-message-attachment-issue/29447/8 "2015-05-31T21:57:47Z")

</div>

What happens with old posts?

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [May 31, 2015, 10:09pm UTC](https://meta.discourse.org/t/private-message-attachment-issue/29447/9 "2015-05-31T22:09:46Z")

</div>

This new route is retrocompatible. I’ll work tomorrow on a rake task to migrate to the new pattern.
