Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine the name of a file to download

I need to download a file from a url which has format similar to http://server.com/settings/files/1 when I paste this url in a web-browser this can determine the name of the file to download in this case scheme_563.txt, my question is how I can retrieve the name of the file (which obviously is not included in the url) to download using the wininet functions? currently i am using the HttpQueryInfo function with multiples values like HTTP_QUERY_CONTENT_LOCATION,HTTP_QUERY_CONTENT_DESCRIPTION, etc. but without luck.

like image 528
Salvador Avatar asked Jun 01 '11 09:06

Salvador


People also ask

How do I name a file before downloading it?

Method 1: You can use Wait for Download activity to download a file, then you can use Rename activity to rename it. Method 2: To rename a file before downloading, you can use Http request to download and name the file. You can configure download file name in “Download Resource”.

How do I find the URL of a downloaded file?

If you download a file using google chrome you can see its by using shortcut Ctrl+J or directly go to your downloads and under every download there is its original download URL. If you can't see the complete URL then you can right click on that URL and Copy Link. How do I use a URL?

How do I change the name of a file downloaded from my browser?

Click on the "Edit Menu" > Preferences > General tab. Locate the "Save downloaded files to" section, Click on "Downloads" > "Other"... Browse and indicate your new download location.


1 Answers

According to http://en.wikipedia.org/wiki/List_of_HTTP_header_fields, the Content-Disposition header includes this information

Content-Disposition: attachment; filename=fname.ext

Maybe this optional header is available in the response to a HTTP GET or HEAD request in this case.

Note that the filename may be encoded - see How to encode the filename parameter of Content-Disposition header in HTTP? for a discussion

like image 81
mjn Avatar answered Sep 17 '22 17:09

mjn