No internet connection
  1. Home
  2. Ideas

Keep attached file name intact while downloading

By @melanopsis2018-08-10 21:54:27.487Z

When a user downloads an attachment, the file name seen in the post is replaced with some generated (hashed?) name which forces user to rename the file. It would be desirable to keep the original file name intact during download.
Thank you!

  • 9 replies
  1. KajMagnus @KajMagnus2018-08-11 08:38:22.672Z2018-08-11 11:25:34.823Z

    Ok yes this is a bit annoying to me too. I'd like to fix this. The files are hashed, because then 1) if different people upload the same file, no additional disk space will get used. And 2) when downloading, even if files were uploaded using different names, they'll get the same hash and will get cached by the CDN (if a CDN is in use).

    There's a new HTML5 download= attribute that works like so: <a href="path-to-file" download="name-to-give-to-saved-file.txt">...<a> (see this StackOverflow answer) that lets one specify the name of the file name after download — but seems it won't work together with a CDN, because requires the same origin. (Hmm maybe there's some way around this)

    Anyway, in your case (on-premise), I suppose there is no CDN. Also, maybe most people won't setup a CDN. So maybe downloading files, using their original names, should be the default behavior. And there could be a config option, to enable the hash name optimization.

    (On the disk, they could be saved using hashes though, that'd cause no problems.)

    Fixing this is a little bit tricky: I'll need a table that maps file names, to file hashes, and maybe review some reference counting code (that tracks how many times each uploaded file, is linked / used — when the ref counts gets 0 they're supposed to get auto deleted). So probably this will have to wait for a while.

    Hmm I suppose I can add the HTML5 download=... attribute, always, and then it ought to work, for you since you don't use any CDN. I'll give this a try.

    1. M@melanopsis2018-08-14 21:43:10.632Z

      Thanks @KajMagnus, definitely no CDN on our side.

    2. @KajMagnus marked this topic as Planned 2018-08-11 08:38:34.114Z.
    3. In reply tomelanopsis:
      KajMagnus @KajMagnus2018-08-20 12:21:26.758Z

      I've fixed this in a GitHub branch now, by adding the download=... attribute. So your files will have the same name, when downloaded, as when uploaded. The fix will be included in the next release, in maybe 5 days. (And works only when no CDN is in use.)

      1. M@melanopsis2018-08-20 19:07:18.204Z

        Thank you @KajMagnus

        1. KajMagnus @KajMagnus2018-08-27 09:13:50.730Z

          Hi again, sorry for the delay. I'm writing end-to-end tests for a new feature (namely drafts, so the software remembers what one started typing, if one closes the browser and continues writing, later, + listing all one's drafts in case one forgot what one was doing :- P ).

          And this took longer than what I expected.

          1. M@melanopsis2018-08-27 20:49:49.265Z

            No worries. The feature you are describing will be really useful.

      2. M@melanopsis marked this topic as Started 2018-09-12 22:52:25.147Z.
      3. M@melanopsis marked this topic as Done 2018-09-12 22:52:26.215Z.