nicolasff / webdis

A Redis HTTP interface with JSON output
https://webd.is
BSD 2-Clause "Simplified" License
2.83k stars 304 forks source link

Add param "filename" to allow for nice looking filenames #21

Closed TheNicholasNick closed 13 years ago

TheNicholasNick commented 13 years ago

http://www.ietf.org/rfc/rfc1806.txt

Using the content-disposition header with value of "attachment; filename=param[filename]" then requests that look like this

/GET/acme_inc:awesome_report:19:pdf.pdf?type=application/pdf&filename=awesome_report_20110506.pdf

in a browser are saved as "awesome_report_20110506.pdf" instead of "acme_inc:awesome_report:19:pdf.pdf" also by making it an attachment the browser prompts to save/open rather than using the pdf plugin to render the pdf in the current tab (in this example, request in a browser)

whatcha think?

edit: I currently use this in a sinatra project... http://rubydoc.info/gems/sinatra/1.2.6/Sinatra/Helpers:send_file http://rubydoc.info/gems/sinatra/1.2.6/Sinatra/Helpers:attachment

send_file("/location/of/file/unique_id.pdf", {:filename => "quote.pdf"})

nicolasff commented 13 years ago

Hi Nicholas,

Good suggestion! I will implement it this week.

TheNicholasNick commented 13 years ago

cool - look forward to using it :)

nicolasff commented 13 years ago

Hi,

Just to let you know, this is implemented (but not pushed yet). Expect it soon :-)

TheNicholasNick commented 13 years ago

excellent, will be pushing it live as soon as u push it :)

give the users of this app a nice filename instead of the redis key,

thanks

nicolasff commented 13 years ago

Nicholas,

Would you mind trying out the master version? I've just pushed some changes implementing your suggestion.

TheNicholasNick commented 13 years ago

sweet, playing with this today - thanks

TheNicholasNick commented 13 years ago

great it works.

however it looks like you have tweaked the request parsing too.

before this change my GET request was /GET/acme_inc:awesome_report:19:pdf.pdf and now I have to leave off the extension /GET/acme_inc:awesome_report:19:pdf

if this is suppose to be happening great, might want to update the readme to explain this though :)

(this is with or without the filename param, I have to leave the extension off)

cheers

nicolasff commented 13 years ago

Indeed, unknown extensions are now considered part of the key (see ticket #25).

TheNicholasNick commented 13 years ago

ahh that makes sense ;)

this works perfectly and as expected, not sure i'm going to find any bugs as I'm not doing anything weird (0-9,a-z,,zero spaces...)_

thanks