nokonoko / Pomf

Simple file uploading and sharing, source for the now shut down site Pomf.se
MIT License
465 stars 98 forks source link

Give original filename to HTTP clients on download request for certain compression formats #32

Open wareya opened 9 years ago

wareya commented 9 years ago

Some compression formats (bz2, etc) compress a single file where the contained file is named after the archive itself. For example, "gamearchive.packme.bz2" decompresses to a file called whatever is to the left of the bz2 extension. This isn't a problem for nested archives (such as tar.gz) but it can make some single-file uploads useless due to losing the filename unless they encapsulate the archive in another useless file or vice versa.

thehowl commented 9 years ago

this would require a php script to be executed for each request, which obviously slows down the downloading of the files and puts some unnecessary server load.

On 5 May 2015 05:44:36 CEST, Alexander Nadeau notifications@github.com wrote:

Some compression formats (bz2, etc) compress a single file where the contained file is named after the archive itself. For example, "gamearchive.packme.bz2" decompresses to a file called whatever is to the left of the bz2 extension. This isn't a problem for nested archives (such as tar.gz) but it can make some single-file uploads useless due to losing the filename unless they encapsulate the archive in another useless file or vice versa.


Reply to this email directly or view it on GitHub: https://github.com/nokonoko/Pomf/issues/32

Sent from my Android device with K-9 Mail. Please excuse my brevity.

wareya commented 9 years ago

Good response.

It makes me wonder if there's another way to do it. I know that some sites out there have a suffix on the URL which denotes the download filename, but as you said implementing it in an easy way would be a problem.

thehowl commented 9 years ago

well, i do know there's already a way for it that is being used for .tar.gz and some, here: https://github.com/nokonoko/Pomf/blob/master/static/includes/settings.inc.php

check the array at the bottom.

On 5 May 2015 10:47:20 CEST, Alexander Nadeau notifications@github.com wrote:

Good response.

It makes me wonder if there's another way to do it. I know that some sites out there have a suffix on the URL which denotes the download filename, but as you said implementing it in an easy way would be a problem.


Reply to this email directly or view it on GitHub: https://github.com/nokonoko/Pomf/issues/32#issuecomment-98997618

Sent from my Android device with K-9 Mail. Please excuse my brevity.

wareya commented 9 years ago

That seems to work at upload time, no?

Anyways, I think a partial solution would be script that's separate from the normal download method specifically for people who need to post links that generate the original filename. Something like a url of /alias/cllzda.bz2/gamearchive.packme.bz2

Dunno, depends how the servers are set up.

thehowl commented 9 years ago

yeah, and what would be the problem? it still saves them with the full extension rather than only .gz and such

anyway, i guess the alias would actually be possible. it would just put a small load on nginx due to regex rewrites but that's definetely possible.

maybe it could be on another subdomain specific for alias, so that it doesn't affect the main a.pomf.se.

On 5 May 2015 11:41:16 CEST, Alexander Nadeau notifications@github.com wrote:

That seems to work at upload time, no?

Anyways, I think a partial solution would be script that's separate from the normal download method specifically for people who need to post links that generate the original filename. Something like /alias/cllzda.bz2/gamearchive.packme.bz2


Reply to this email directly or view it on GitHub: https://github.com/nokonoko/Pomf/issues/32#issuecomment-99011825

Sent from my Android device with K-9 Mail. Please excuse my brevity.

wareya commented 9 years ago

Doing that at upload time is good for paired extension like tar.gz, but over here it would maybe just be useful for changing the kind of URL that the uploader receives when they're done.

anyway, i guess the alias would actually be possible. it would just put a small load on nginx due to regex rewrites but that's definetely possible.

hiding the functionality behind an FAQ, cheat sheet, or activating it based on what kind of file was uploaded like above would go a ways to making sure only people who actually need it use a function like this

maybe it could be on another subdomain specific for alias, so that it doesn't affect the main a.pomf.se.

Good idea.

nokonoko commented 9 years ago

I'll look into it, very busy atm.

A easy solution would be to detect archive formats and store their original filename and give back a download link such as a.pomf.se/RAND_STRING/arch.1.ext.

That way the file will still be useable and not having to dabble around with extra subdomains.

NuckChorris commented 9 years ago

What about just when it ends in .gz read back to the previous dot as the kept extension?

wareya commented 9 years ago

Thanks @nokonoko

@NuckChorris sometimes people have files without proper extensions or non-extensions after a dot

NuckChorris commented 9 years ago

If it doesn't have an extension before the .gz, maintaining the file name will do nothing. If it does, that will fix it.

As for not-extension-but-has-dot, can you think of any situation where a .gz file with another dot earlier in the name isn't the extension?

wareya commented 9 years ago

If it doesn't have an extension before the .gz, maintaining the file name will do nothing.

Sometimes the filename itself has semantic meaning.

As for not-extension-but-has-dot, can you think of any situation where a .gz file with another dot earlier in the name isn't the extension?

For example, hidden files on unix systems? People do crazy things with filenames; extensions-after-dots are just a very useful tradition of sorts

NuckChorris commented 9 years ago

I agree that pond should replay the file name on download, but I'm pointing out that most non-semantic issues could be solved by reading back to the previous dot.

I keep saying pomf needs a server to do X-Sendfile

wareya commented 9 years ago

Looks like we're in agreement