Android Question Download and Safe File (from PHP)

mw71

Active Member
Licensed User
Longtime User
Hi

i would like download ab File from a Webserver.
The URL is like: www.Server.net/script.php?r=XX

The Server generate a GPX File for Download.

Whith this Code a can Download the File, unfortunately i cant get the File Name from the Server.
(with the Browser i get the File Name)
B4X:
Dim h_dl_gpx As HttpJob
Dim url As String = "https://www.Server.net/script.php?r=XX"

h_dl_gpx.Initialize("TestGPX",Me)
h_dl_gpx.Download(url)

Wait For (h_dl_gpx) JobDone(h_dl_gpx As HttpJob)

How can i get the Filename or save the File under a defined File Name??
 

DonManfred

Expert
Licensed User
Longtime User
You can not get the filename this way. You need to have another phpscript which provides the filename.

To save the result to any place you need to use the outputstream like for any other download. Search the forum; there are hundrets of similar questions.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

mw71

Active Member
Licensed User
Longtime User
in the Browser the "save as" Window is open

It is not required. OkHttpUtils2 v2.70 allows you to access the response object with Job.Response.
thanks Erel, i see, i use the HttpUtils2 version 2.01 Class Modul, time for Update and Check.

At the moment i use a (little bit more) code and save the File under a defined file name.
 
Upvote 0
Top