Upload file name not kept on download


(Joshua Rosenfeld) #1

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.


Attached .txt canot download
PNG's a no show
Uploaded zip file is renamed
Where is nginx.conf
(R Zarni) #2

I met this question on my forum. and this


(Daniela) #4

Also on my forum updated today:


(Jeff Atwood) #7

We need to fix this @zogstrip


(Leo Davidson) #8

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


(Candido Cleyton) #9

This error also happens in my forum


(Jeff Atwood) #10

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.


(Leo Davidson) #11

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


(Jeff Atwood) #12

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


(Leo Davidson) #13

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:


(Joshua Rosenfeld) #14

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.


(David Taylor) #15

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


(Bertrand Bellenot) #17

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


(Stephen Chung) #18

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

I thought it was a feature!


(Leo Davidson) #19

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.


(Jeff Atwood) #20

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


(Régis Hanol) #21

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


(Stephen Chung) #22

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?


(Régis Hanol) #23

Finally pushed a fix

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


Uploaded zip file is renamed
(Régis Hanol) #24

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://meta-s3-cdn.freetls.fastly.net/original/3X/e/a/ea79f5d0354286fa7bde1bbd268c905c33a6b086.txt
  • SHA = ea79f5d0354286fa7bde1bbd268c905c33a6b086