Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 20th February 2011, 09:20   #1
zivha
Junior Member
 
Join Date: Aug 2010
Posts: 44
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?
zivha is offline   Reply With Quote
Old 20th February 2011, 11:52   #2
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,841
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.
MSG is offline   Reply With Quote
Old 20th February 2011, 11:58   #3
zivha
Junior Member
 
Join Date: Aug 2010
Posts: 44
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.
zivha is offline   Reply With Quote
Old 20th February 2011, 12:44   #4
jiake
Senior Member
 
jiake's Avatar
 
Join Date: Oct 2007
Location: Xi'an, China
Posts: 194
${WordFind} "http://example.org/foo/bar.baz" "/" "-1" $R0
inetc::get "http://example.org/foo/bar.baz" $R0

An NSIS fan from China, my name is Jia Ke (pinyin).
Email: jiake@vip.qq.com
Messenger: jiake@live.in
QQ (Chinese IM): 550771955
jiake is offline   Reply With Quote
Old 20th February 2011, 12:57   #5
zivha
Junior Member
 
Join Date: Aug 2010
Posts: 44
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.
zivha is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump