Page 1 of 1
Downloading zip files via URL
Posted: Tue Oct 06, 2015 12:04 pm
by gstone
Hello.
I have had some trouble trying to download another section of resource files for my Android application.
I have set-up a PHP file on my server where if the correct vars are used it would return with a download file (.zip)
Code: Select all
"http://Address_here/listener.php?vAssetNo=h001234"
The command works on my browser within OS X and Windows 8.1 - 10 using chrome on both OS.
It initiates on my Android application but no downloads take place within my browser session, it does however download on the mobile chrome app but subsequently the file is not readable.
Anybody had trouble downloading a .Zip file via http before? Also not sure on how to call the file once it lives within the download folder on the phone itself...
Any help would be appreciated.
Cheers
Re: Downloading zip files via URL
Posted: Tue Oct 06, 2015 1:23 pm
by rblackmore245
Are you trying to download a file from within the native browser within live code ?
or by using the URL method ? as I'm not sure livecode would allow the native browser running within a livecode app to download a file that way.
Re: Downloading zip files via URL
Posted: Tue Oct 06, 2015 1:42 pm
by gstone
Hi, thanks for the reply.
I have been using a get URL method, I hoped once the URL finished loading the download would then initiate.
Here is an example of what my basic attempt had been;
Code: Select all
on mouseUp
put "MOB-H000068" into tAssetNo
put "vAssetNo=" into URLVar
--put "vAssetNo=" & tAssetNo into field "PHP"
get URL ("http:/localhostaddress/listener.php?vAssetNo=h001234")
--put the result into field "Results"
end mouseUp
Not sure if this would work? No success as of yet.
Re: Downloading zip files via URL
Posted: Tue Oct 06, 2015 2:01 pm
by SparkOut
[indent][/indent]On phone keyboard at the moment so hard to give full params but try
Code: Select all
put specialFolderPath("documents") & "/filename.zip" into tDownload
put URL ("http://address/path") into URL("binfile:" & tDownload)
documents folder on Android is case sensitive. By default it will be readable only by your LiveCode app. If you need to unzip it with another aappointment or find with a file manager you need to download it to a public folder, such as the SD card.
Re: Downloading zip files via URL
Posted: Tue Oct 06, 2015 2:55 pm
by gstone
Hi,
the filename would be ever changing as files would be updated if a change is requested from the main system.
So the file would be haylo.devicename.iygwrfiyg.zip its a unique ID for the main system.
I would want to unzip the file within the livecode app, the zip could contain 1 or more files.
Thanks appreciate the reply!
Re: Downloading zip files via URL
Posted: Tue Oct 06, 2015 3:13 pm
by rblackmore245
When I have created apps that downloaded zip files before just use the urlProgress to check when the zip file has been downloaded then unzip the file to a location.
I have had a few problems with it throwing the downloaded status before it had finished on some older devices when downloading large zip files over 200mb.
on urlProgress pURL, pStatus, pBytesDone, pBytesTotal
switch pStatus
case "downloaded"
unzip files here
end switch
end urlProgress
Re: Downloading zip files via URL
Posted: Wed Oct 07, 2015 8:16 am
by gstone
Thank you so much, works like an absolute charm!
Project can now start moving forwards again, again thanks for all your help.
Gary