Upload file name not kept on download

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 (11 Bytes)

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

5 Likes

I met this question on my forum. and this

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

1 Like

Also on my forum updated today:

2 Likes

We need to fix this @zogstrip

6 Likes

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.)

This error also happens in my forum

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.

1 Like

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

1 Like

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

3 Likes

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:

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.

2 Likes

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

3 Likes

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

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

I thought it was a feature!

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 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.

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

2 Likes

Yup, will get it fixed this week. :memo:

9 Likes

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?

1 Like

Finally pushed a fix

https://github.com/discourse/discourse/commit/7ab49acac24c89bf8353364e6cad0db649c57e98

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

9 Likes

In the rails console

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

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

Example

  • URL = https://d11a6trkgmumsb.cloudfront.net/original/3X/e/a/ea79f5d0354286fa7bde1bbd268c905c33a6b086.txt
  • SHA = ea79f5d0354286fa7bde1bbd268c905c33a6b086
6 Likes