Android Upload / Download zip files issues

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
istech
Posts: 211
Joined: Thu Sep 19, 2013 10:08 am

Android Upload / Download zip files issues

Post by istech » Thu Mar 06, 2014 3:10 pm

I have been using a script by "jmburnod" "http://forums.runrev.com/phpBB2/viewtop ... =8&t=13466" to test out downloading and extracting zip files.

However I have only been able to get it working on desktop not Android.

However checking the code I do not see why it does not work on Android as all the code (as far as I can see) is compatible. So as I searched and came up with this post by "kray" http://livecodejournal.com/forum/viewto ... ?f=24&t=92

Is this still the case with the latest build of LC with Android Apps? This libURLDownloadToFile is unreliable?

Just to add, I am using the latest build of LC, Have added internet, revZip, and write to external storage to the standalone and use Android 4.3 on the Android Emulator.

I have tried small files and large files the download function just does not activate.

Thanks in advanced guys

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Android Upload / Download zip files issues

Post by Simon » Thu Mar 06, 2014 10:44 pm

Hi istech,
I don't know why that libURLDownloadToFile entry still says it's good for mobile. I don't think it ever worked on mobile?
Go with Ken Ray's "load" or use "put url".
Nice that load has that pData, makes it easy.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Android Upload / Download zip files issues

Post by jmburnod » Fri Mar 07, 2014 1:26 pm

Hi Simon

LibUrldownloadToFile works on mobile. I tested it on IOS without mistake.
https://alternatic.ch

istech
Posts: 211
Joined: Thu Sep 19, 2013 10:08 am

Re: Android Upload / Download zip files issues

Post by istech » Fri Mar 07, 2014 3:32 pm

Thanks for the reply

This issue apparently only happens on Android devices. If you have one give it a try and let us know.

Presently I am trying to get a working script with load url. Any pointers would be great in any case.

Code: Select all

on mouseUp
   load url "http://www.alternatic.ch/jmb/devrev/images50.zip"
   hide scrollbar "ProgressBar"
end mouseUp

on urlProgress pUrl, pStatus,pData
  if the number of items in pStatus = 3 then ##will not work unless web server sends total
  if the visible of scrollbar "ProgressBar" = false then
  put the last item of pStatus into tTotalBytes
  set the startValue of scrollbar "ProgressBar" to 0
  set the endValue of scrollbar "ProgressBar" to tTotalBytes
  show scrollbar "ProgressBar"
end if
set the thumbPosition of scrollbar "ProgressBar" to item 2 of pStatus
end if
if pStatus is "downloaded" then
   answer "Finished downloading" with "Okay"
      put pData into URL ("binfile:" & specialfolderpath("engine") &  "/images50.zip")
      hide scrollbar "ProgressBar"
      unload url "http://www.alternatic.ch/jmb/devrev/images50.zip"
      send "unZip" to me in 2 seconds
   end if
end urlProgress

command unZip
   
   put specialFolderPath("engine") & "/images50.zip" into TempFile
   put specialFolderPath("engine") & "/" into TargetFile -- Problem part, previous one was linked to a map in a map, because the zip is a map.
   
   revZipOpenArchive TempFile, "read"
   put RevZipEnumerateItems(TempFile) into tList
   
   repeat for each line i in tList
     
      if i = empty then
         next repeat
      end if
     
      revZipExtractItemToFile TempFile, i, (TargetFile & i)
     
   end repeat
   
   revZipCloseArchive TempFile
   delete file TempFile
   send "fileCheck" to me in 1 second
end unZip

command fileCheck
      if there is a file (specialfolderpath("engine") & "/pres.png") then
         answer "it works!! Great!"
      else
         answer "needs more work"
      end if
end fileCheck

At the moment it is in "needs more work" :)

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Android Upload / Download zip files issues

Post by jmburnod » Fri Mar 07, 2014 6:43 pm

Hi,
Are you sure we can download a file to the engine folder ?
I never did it
https://alternatic.ch

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Android Upload / Download zip files issues

Post by Klaus » Fri Mar 07, 2014 6:52 pm

No, we CAN'T! :D

@istech:
specialfolderpath("engine") is TABOO for writing! 8)
Use specialfolderpath("cache") or specialfolderpath("documents") to store the loaded zip file!

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Android Upload / Download zip files issues

Post by Simon » Fri Mar 07, 2014 9:03 pm

Hi,
put pData into URL ("binfile:" & specialfolderpath("engine") & "/images50.zip")
That's not good, you can't write to the engine folder.
put pData into URL ("binfile:" & specialfolderpath("documents") & "/images50.zip")
is where you want to put the file.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

istech
Posts: 211
Joined: Thu Sep 19, 2013 10:08 am

Re: Android Upload / Download zip files issues

Post by istech » Fri Mar 07, 2014 9:44 pm

Ah thanks I will give it a shot.

Klaus you know I like doing things with the specialfolderpath you shouldn't or can't 8)

Can we copy to the engine location after we download? Or is it strictly no go. (gone to have a look at the docs again)

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Android Upload / Download zip files issues

Post by jmburnod » Fri Mar 07, 2014 10:24 pm

Hi istech,
Can we copy to the engine location after we download?
No.
As Klaus said
specialfolderpath("engine") is TABOO for writing!
https://alternatic.ch

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Android Upload / Download zip files issues

Post by Klaus » Fri Mar 07, 2014 11:16 pm

istech wrote:Klaus you know I like doing things with the specialfolderpath you shouldn't or can't 8)
No, I don't know, but it is up to you to let your device EXPLODE! :D

Post Reply