Downloading zip files via URL

The place to discuss anything and everything about running your LiveCode on Android

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
gstone
Posts: 17
Joined: Wed Aug 19, 2015 4:19 pm
Location: United Kingdom
Contact:

Downloading zip files via URL

Post by gstone » Tue Oct 06, 2015 12:04 pm

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

rblackmore245
Posts: 67
Joined: Fri Jun 12, 2015 9:42 am

Re: Downloading zip files via URL

Post by rblackmore245 » Tue Oct 06, 2015 1:23 pm

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.

gstone
Posts: 17
Joined: Wed Aug 19, 2015 4:19 pm
Location: United Kingdom
Contact:

Re: Downloading zip files via URL

Post by gstone » Tue Oct 06, 2015 1:42 pm

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.

SparkOut
Posts: 2358
Joined: Sun Sep 23, 2007 4:58 pm

Re: Downloading zip files via URL

Post by SparkOut » Tue Oct 06, 2015 2:01 pm

[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.

gstone
Posts: 17
Joined: Wed Aug 19, 2015 4:19 pm
Location: United Kingdom
Contact:

Re: Downloading zip files via URL

Post by gstone » Tue Oct 06, 2015 2:55 pm

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!

rblackmore245
Posts: 67
Joined: Fri Jun 12, 2015 9:42 am

Re: Downloading zip files via URL

Post by rblackmore245 » Tue Oct 06, 2015 3:13 pm

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

gstone
Posts: 17
Joined: Wed Aug 19, 2015 4:19 pm
Location: United Kingdom
Contact:

Re: Downloading zip files via URL

Post by gstone » Wed Oct 07, 2015 8:16 am

Thank you so much, works like an absolute charm! :D

Project can now start moving forwards again, again thanks for all your help.

Gary

Post Reply

Return to “Android Deployment”