Module: Down::Utils
- Defined in:
- lib/down/utils.rb
Class Method Summary collapse
-
.filename_from_content_disposition(content_disposition) ⇒ Object
Retrieves potential filename from the “Content-Disposition” header.
-
.filename_from_path(path) ⇒ Object
Retrieves potential filename from the URL path.
Class Method Details
.filename_from_content_disposition(content_disposition) ⇒ Object
Retrieves potential filename from the “Content-Disposition” header.
8 9 10 11 12 13 14 15 |
# File 'lib/down/utils.rb', line 8 def filename_from_content_disposition(content_disposition) content_disposition = content_disposition.to_s filename = content_disposition[/filename="([^"]*)"/, 1] || content_disposition[/filename=(.+)/, 1] filename = CGI.unescape(filename.to_s.strip) filename unless filename.empty? end |
.filename_from_path(path) ⇒ Object
Retrieves potential filename from the URL path.
18 19 20 21 |
# File 'lib/down/utils.rb', line 18 def filename_from_path(path) filename = path.split("/").last CGI.unescape(filename) if filename end |