S sergiones Member Licensed User Longtime User Oct 26, 2016 #1 Hello guys, I need to download xls, xlsx and pdf files from a server that requires two cookies, the links are something like "http://www.example.com/download?i=5555". I use a WebView to show the options for users, when they click a link I'm able to detect the download action with Webview_OverrideUrl, extract the cookies using the GetCookie from CookieManager and add to a HttpJob using SetHeader("Cookie", "mycookiescollection"). I have a confirmation from server that the download was made, so cookies seems to be working fine. My problem is on JobDone. Using this method: Code: Copy If Job.Success = True Then Dim out As OutputStream = File.OpenOutput(File.DirInternal , "filename.xls" , False) File.Copy2(Job.GetInputStream , out) out.Close End if because I don't know the file name (filename.xls). "http://www.example.com/download?i=5555" may be a xls or pdf and the filename is completely different, I have thousands of files and possibilities. An additional information: The cookies are used for the mobile version only (used by Webview), it's not the same as the responsive website version used in browser. If you guys have some sugestion would be very appreciated. I can replace all this code if necessary. Thank you guys!
Hello guys, I need to download xls, xlsx and pdf files from a server that requires two cookies, the links are something like "http://www.example.com/download?i=5555". I use a WebView to show the options for users, when they click a link I'm able to detect the download action with Webview_OverrideUrl, extract the cookies using the GetCookie from CookieManager and add to a HttpJob using SetHeader("Cookie", "mycookiescollection"). I have a confirmation from server that the download was made, so cookies seems to be working fine. My problem is on JobDone. Using this method: Code: Copy If Job.Success = True Then Dim out As OutputStream = File.OpenOutput(File.DirInternal , "filename.xls" , False) File.Copy2(Job.GetInputStream , out) out.Close End if because I don't know the file name (filename.xls). "http://www.example.com/download?i=5555" may be a xls or pdf and the filename is completely different, I have thousands of files and possibilities. An additional information: The cookies are used for the mobile version only (used by Webview), it's not the same as the responsive website version used in browser. If you guys have some sugestion would be very appreciated. I can replace all this code if necessary. Thank you guys!
DonManfred Expert Licensed User Longtime User Oct 26, 2016 #2 Have you tried my suggestion in the other thread? Upvote 0
S sergiones Member Licensed User Longtime User Oct 26, 2016 #3 DonManfred said: Have you tried my suggestion in the other thread? Click to expand... I actually checked some examples and the file name is required before the success event (and the http header). Any other idea? Upvote 0
DonManfred said: Have you tried my suggestion in the other thread? Click to expand... I actually checked some examples and the file name is required before the success event (and the http header). Any other idea?
DonManfred Expert Licensed User Longtime User Oct 26, 2016 #4 The code i posted is before the success of jobdone is raised Upvote 0
S sergiones Member Licensed User Longtime User Oct 26, 2016 #5 DonManfred said: The code i posted is before the success of jobdone is raised Click to expand... It works, I'm able to get the file name, thank you! Upvote 0
DonManfred said: The code i posted is before the success of jobdone is raised Click to expand... It works, I'm able to get the file name, thank you!