Android Question Download unknow files using two cookies

sergiones

Member
Licensed User
Longtime User
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:

B4X:
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
Have you tried my suggestion in the other thread?
 
Upvote 0
Top