# Upload file name not kept on download

**URL:** https://meta.discourse.org/t/upload-file-name-not-kept-on-download/71184
**Category:** Bug
**Created:** [02.Октябрь.2017 14:33:24 UTC](https://meta.discourse.org/t/upload-file-name-not-kept-on-download/71184 "2017-10-02T14:33:24Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [02.Октябрь.2017 14:33:24 UTC](https://meta.discourse.org/t/upload-file-name-not-kept-on-download/71184/1 "2017-10-02T14:33:24Z")

</div>

When downloading uploaded files, the file name is not being set when downloaded. This file was originally named `ilovepie.txt`, but is downloading with a random name. [ilovepie.txt](https://global.discourse-cdn.com/meta/original/3X/e/a/ea79f5d0354286fa7bde1bbd268c905c33a6b086.txt) (11 Bytes)

Edit: file name is maintained on Meta, but fails on Try and Stonehearth.

---

<div class="post-metadata">

### Author: ![appcomq](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/appcomq/32/84767_2.png) [@appcomq](https://meta.discourse.org/u/appcomq)
#### Post date: [02.Октябрь.2017 14:36:38 UTC](https://meta.discourse.org/t/upload-file-name-not-kept-on-download/71184/2 "2017-10-02T14:36:38Z")

</div>

> [@Attached .txt canot download](https://meta.discourse.org/t/attached-txt-canot-download/71026):
>
> I have update to v1.9.0.beta11. There is a new BUG, Attached .txt canot download.

I met this question on my forum. and this

[https://meta.discourse.org/t/failure-function-prevent-anons-from-downloading-files/71182](https://meta.discourse.org/t/failure-function-prevent-anons-from-downloading-files/71182)

---

<div class="post-metadata">

### Author: ![dax](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dax/32/244677_2.png) [@dax](https://meta.discourse.org/u/dax)
#### Post date: [02.Октябрь.2017 14:45:26 UTC](https://meta.discourse.org/t/upload-file-name-not-kept-on-download/71184/4 "2017-10-02T14:45:26Z")

</div>

Также на моём форуме, обновлённом сегодня:

 ![swDkfIN](https://global.discourse-cdn.com/meta/original/4X/4/8/5/4850dad47f75578f34b466a8d771593ef8d9a22e.png)

---

<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: [12.Октябрь.2017 04:31:56 UTC](https://meta.discourse.org/t/upload-file-name-not-kept-on-download/71184/7 "2017-10-12T04:31:56Z")

</div>

We need to fix this @zogstrip

---

<div class="post-metadata">

### Author: ![LeoDavidson](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leodavidson/32/119574_2.png) [@LeoDavidson](https://meta.discourse.org/u/LeoDavidson)
#### Post date: [16.Октябрь.2017 21:58:29 UTC](https://meta.discourse.org/t/upload-file-name-not-kept-on-download/71184/8 "2017-10-16T21:58:29Z")

</div>

I guess whatever causes this isn’t happening everywhere, as this forum is OK.

If you need help tracking down the problem or testing fixes, I’d be happy to assist any way I can. This issue is affecting the forum I run. I’m technical enough to have made some Discourse plugins and poked around on the database side fixing another attachments/import issue (although it’s not my bread & butter), so I’m happy to help if the combination of someone technical with a live system that has the problem is useful.

(No problem if it isn’t needed, of course! I don’t know if it’s a rare problem or something easy to reproduce.)

---

<div class="post-metadata">

### Author: ![Candido\_Cleyton](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/candido_cleyton/32/75290_2.png) [@Candido\_Cleyton](https://meta.discourse.org/u/Candido_Cleyton)
#### Post date: [17.Октябрь.2017 00:19:06 UTC](https://meta.discourse.org/t/upload-file-name-not-kept-on-download/71184/9 "2017-10-17T00:19:06Z")

</div>

This error also happens in my forum

---

<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: [17.Октябрь.2017 00:24:37 UTC](https://meta.discourse.org/t/upload-file-name-not-kept-on-download/71184/10 "2017-10-17T00:24:37Z")

</div>

> [@jomaxro](#):
>
> Edit: file name is maintained on Meta, but fails on Try and Stonehearth.

This means it is a multisite bug for the record. Enterprise sites that have their own container won’t be affected, if this is the tested behavior.

---

<div class="post-metadata">

### Author: ![LeoDavidson](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leodavidson/32/119574_2.png) [@LeoDavidson](https://meta.discourse.org/u/LeoDavidson)
#### Post date: [17.Октябрь.2017 06:18:36 UTC](https://meta.discourse.org/t/upload-file-name-not-kept-on-download/71184/11 "2017-10-17T06:18:36Z")

</div>

> [@codinghorror](#):
>
> This means it is a multisite bug for the record.

FWIW I’m seeing the problem on a single-site forum, self-installed using the Docker image.

---

<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: [17.Октябрь.2017 06:41:43 UTC](https://meta.discourse.org/t/upload-file-name-not-kept-on-download/71184/12 "2017-10-17T06:41:43Z")

</div>

Oh interesting you are correct, I can see this on my own self-hosted Discourse as well. Perhaps a CDN interaction?

---

<div class="post-metadata">

### Author: ![LeoDavidson](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leodavidson/32/119574_2.png) [@LeoDavidson](https://meta.discourse.org/u/LeoDavidson)
#### Post date: [17.Октябрь.2017 22:29:30 UTC](https://meta.discourse.org/t/upload-file-name-not-kept-on-download/71184/13 "2017-10-17T22:29:30Z")

</div>

> [@codinghorror](#):
>
> Perhaps a CDN interaction?

I’m not using a CDN here FWIW. Fairly vanilla setup, other than turning on HTTPS/SSL and doing the initial import from phpBB, and a few plugins.

Here’s the list of plugins, in case it helps spot a commonality:

 ![200dpi_wc10472_chrome](https://global.discourse-cdn.com/meta/original/3X/0/d/0d2fe7d979ba801f25e1e5238ac3b87e32938c6b.png)

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [17.Октябрь.2017 23:32:59 UTC](https://meta.discourse.org/t/upload-file-name-not-kept-on-download/71184/14 "2017-10-17T23:32:59Z")

</div>

Perhaps the CDN we use on Meta (Fastly) is doing something different and preventing the bug…so it’s not that CDN is causing the issue (or Leo wouldn’t see the issue), but that the unique CDN here stops the bug.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [17.Октябрь.2017 23:35:17 UTC](https://meta.discourse.org/t/upload-file-name-not-kept-on-download/71184/15 "2017-10-17T23:35:17Z")

</div>

Maybe because Meta uses S3 storage, but other sites like try/codinghorror don’t?

---

<div class="post-metadata">

### Author: ![Bertrand\_Bellenot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bertrand_bellenot/32/91890_2.png) [@Bertrand\_Bellenot](https://meta.discourse.org/u/Bertrand_Bellenot)
#### Post date: [23.Октябрь.2017 07:55:04 UTC](https://meta.discourse.org/t/upload-file-name-not-kept-on-download/71184/17 "2017-10-23T07:55:04Z")

</div>

We have the same problem with our docker based Discourse instance (since a couple of weeks)…

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [23.Октябрь.2017 13:48:48 UTC](https://meta.discourse.org/t/upload-file-name-not-kept-on-download/71184/18 "2017-10-23T13:48:48Z")

</div>

Filenames are _never_ preserved for me for local uploaded files. Has been on day one.

I thought it was a _feature_!

---

<div class="post-metadata">

### Author: ![LeoDavidson](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leodavidson/32/119574_2.png) [@LeoDavidson](https://meta.discourse.org/u/LeoDavidson)
#### Post date: [24.Октябрь.2017 00:36:58 UTC](https://meta.discourse.org/t/upload-file-name-not-kept-on-download/71184/19 "2017-10-24T00:36:58Z")

</div>

It seems another aspect of this is that attachments which contain plain text will be displayed by the browser instead of being downloaded.

We used to be able to left-click them and they’d download, but now we have to use right-click \> save-as to do that.

To see what I mean, go to [this post on our forum](https://resource.dopus.com/t/sort-folder-tabs-on-demand-or-when-listers-open/26890) and click either of the **Sort Tabs.dcf** or **Sort Tabs.js.txt** download links in the first post. Both contain text data (the .dcf is XML and the .js.txt is jscript), and you’ll get a screen full of that instead of a file downloaded if you left-click.

(Checked with both Chrome/Windows and IE/Windows in case it was a browser change.)

Edit: I think the download counts are no longer updating, either. Seems as though the whole of the download processing stuff is not happening when downloads are clicked.

---

<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: [24.Октябрь.2017 12:43:41 UTC](https://meta.discourse.org/t/upload-file-name-not-kept-on-download/71184/20 "2017-10-24T12:43:41Z")

</div>

Yes this is a bug, @zogstrip will look into it.

---

<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: [24.Октябрь.2017 13:26:26 UTC](https://meta.discourse.org/t/upload-file-name-not-kept-on-download/71184/21 "2017-10-24T13:26:26Z")

</div>

Yup, will get it fixed this week. 📝

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [24.Октябрь.2017 13:40:39 UTC](https://meta.discourse.org/t/upload-file-name-not-kept-on-download/71184/22 "2017-10-24T13:40:39Z")

</div>

By the way, while you’re at it, is there any way to modify/edit the filename?

That’s because people upload files and they don’t take care to give meaningful names sometimes.

It would be nice to be able to edit the filename after they got uploaded.

A Rails command perhaps?

---

<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: [27.Октябрь.2017 16:48:31 UTC](https://meta.discourse.org/t/upload-file-name-not-kept-on-download/71184/23 "2017-10-27T16:48:31Z")

</div>

Finally pushed a fix

[https://github.com/discourse/discourse/commit/7ab49acac24c89bf8353364e6cad0db649c57e98](https://github.com/discourse/discourse/commit/7ab49acac24c89bf8353364e6cad0db649c57e98)

We somehow missed the deprecation warnings and it broke when we upgraded to Rails 5.1.

---

<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: [27.Октябрь.2017 16:59:34 UTC](https://meta.discourse.org/t/upload-file-name-not-kept-on-download/71184/24 "2017-10-27T16:59:34Z")

</div>

> [@schungx](#):
>
> A Rails command perhaps?

In the rails console

```ruby
Upload.find_by(sha1: "<sha>").update_columns(original_filename: "new_filenane.ext")

```

With “`<sha>`” being the filename in the upload url.

Example

- URL = `https://global.discourse-cdn.com/meta/original/3X/e/a/ea79f5d0354286fa7bde1bbd268c905c33a6b086.txt`
- SHA = `ea79f5d0354286fa7bde1bbd268c905c33a6b086`

[Следующая страница](https://meta.discourse.org/t/upload-file-name-not-kept-on-download/71184.md?page=2)
