How can i download file from internet, when it don't has a direct URL? Main question - Where can i take name and extension for file?
For example when URL = "defaultSite.com/topic/9772.png" we can take last part of string and create file "9772.png", where we save stream of bytes.
But from URL like:
http://www.skype.com/go/getskype
https://www.dropbox.com/download?plat=win
we can't take file name, however byte stream we can save with no problem. So how can i download file like that?
upd: MIME can't help, i think, becouse file can have specific (user created) extension, or it return to me application/octet-stream even for .exe file. Besides problem whit file name left.
upd2: Yes, server return headers, but it may be without file name. There from skype example:
conn.getHeaderField 0 : HTTP/1.1 200 OK
conn.getHeaderField 1 : nginx
conn.getHeaderField 2 : application/octet-stream
conn.getHeaderField 3 : 30619240
conn.getHeaderField 4 : Thu, 28 Feb 2013 19:35:47 GMT
conn.getHeaderField 5 : bytes
conn.getHeaderField 6 : max-age=86400
conn.getHeaderField 7 : Thu, 04 Apr 2013 14:52:26 GMT
conn.getHeaderField 8 : keep-alive
conn.getHeaderField 9 : S
I need a reliable way to get name and extension.