zivha
20th February 2011 10:20 UTC
Inetc and local file names
Hello,
I need an installer to download a file using a URL entered by the user during installation. I know how to use inetc the problem is that inetc requires a local filename (the file which is stored locally with the content downloaded) but I need the file name to be the file name as specified by the server the file is downloaded from. For example if you use Internet Explorer to download a file from a URL it will suggest the filename to store the data (based on the URL or on the http headers). Is there anyway to do the same, to have inetc figure out the filename on its own?
MSG
20th February 2011 12:52 UTC
err... I think you're confusing local and server filenames. If you have the URL to a file on a server, then that URL already contains the exact filename. How else, after all, could the server know what it should send to the user? When you download http://example.org/foo/bar.baz , the file 'bar.baz' will be downloaded to your computer. The name you give it locally, on your computer, is entirely up to you.
I never used inetc, but I would expect that, by default, it saves a file to its own name. So $INSTDIR\bar.baz, to follow the above example.
zivha
20th February 2011 12:58 UTC
MSG - I am not confusing but maybe my explanation was not worded very well.
Lets take your example, http://example.org/foo/bar.baz - I'd like inetc to do exactly what you said save the file locally as bar.baz - the problem is that according to the inetc plugin you must supply a local file name so inetc get would look something like:
inetc::get http://example.org/foo/bar.baz "bar.baz"
I need to specify the file name which I can not really know...
And by the way the URL does not need to always specify the file name the server has many ways of knowing the filename and the filename can be returned as a Content-Disposition http header - which is why just parsing the URL is not a safe way to figure out the filename, you need to actually HEAD the URL and parse the headers which I assume inetc is already doing.
jiake
20th February 2011 13:44 UTC
${WordFind} "http://example.org/foo/bar.baz" "/" "-1" $R0
inetc::get "http://example.org/foo/bar.baz" $R0
zivha
20th February 2011 13:57 UTC
It is not safe to assume the URL format is that simple and has the filename at its end, there are so many different possible URLs for example:
http://example.org/foo/bar.baz?id=7
or simply http://example.org/foo/bar
where the http header returned include the file name in a Content-Disposition header.
It needs to be implemented in inetc or some other plugin that is more intimate with the networking.