Unzip file and show it.

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

FireWorx
Posts: 362
Joined: Wed Sep 07, 2011 9:39 pm

Re: Unzip file and show it.

Post by FireWorx » Thu Feb 28, 2013 1:46 am

Ok I renamed my pdf file as imagesApp and removed the .pdf extention and zipped it and then uploaded it to my server and also renamed a folder full of non decompressed pdf's as imagesApp and uploaded them to my web server one at a time.

I used the following code below exactly as presented in this thread and executed it from a button in the simulator. The imagesApp.zip file does get downloaded to the documents folder however it does not de compress and delete itself. I tried both the individual file and the folder.

Here is the code

on mouseup
downloadFiles
unZip
end mouseup

on downloadFiles
   libUrlDownloadToFile "http://myservername.on-rev.com/Maps/magesApp.zip", specialfolderpath ("documents") & "/imagesApp.zip"
   send unZip to me in 0 milliseconds
end downloadFiles

command unZip
    put specialFolderPath("documents") & "/imagesApp.zip" into TempFile
   put specialFolderPath("documents") & "/" into TargetFile
   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
  end unZip

I use the code below to confirm that the zip file did get downloaded and that the compression did not take place with the code below
I use the code

on mouseUp
if the environment is mobile then
put specialFolderPath("documents") into tpath
set the defaultfolder to tpath -- so you can get the folder names
put the folders into tMyList -- get a list of folder names
put the files into tList -- a list of the file names
answer tList -- returns imagesApp.zip
answer tMyList -- returns one unrelated folder name that I have copied over on openstack
end if
end mouseUp

So what do you think? NOTE: the file i am trying to decompress is a .pdf file and the folder I would like to decompress is a folder holding non individually compressed pdf's and I have zipped the folder itself. I cant seem to decompress anything.
dave

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

Re: Unzip file and show it.

Post by Simon » Thu Feb 28, 2013 2:02 am

Hi Dave,
I didn't mean you had to remove the .pdf extensions :(

I'll tell you what Chris had a problem with, the zip file had a folder name in it so it created a sub directory in the destination folder.
on revZipExtractItemToFile TempFile, i, (TargetFile & i) "i" contained /New folder/extacted.pdf so looking for the file at TargetFile came up empty.

To figure out what it was he added a fld and put tList into it. Take a look.

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

FireWorx
Posts: 362
Joined: Wed Sep 07, 2011 9:39 pm

Re: Unzip file and show it.

Post by FireWorx » Thu Feb 28, 2013 4:43 am

My script is not executing that far down.

command unZip
put specialFolderPath("documents") & "/imagesApp.zip" into TempFile
   put specialFolderPath("documents") & "/" into TargetFile
    answer "made it this far" -- this line of code executes
revZipOpenArchive TempFile, "read"
answer "made it this far too" -- this line of code never executes so figure must be an issue with revZipOpenArchive

However I know there is an imagesApp.zip in the documents folder because this code says there is...

on mouseUp
if the environment is mobile then
put specialFolderPath("documents") into tpath
set the defaultfolder to tpath -- so you can get the folder names
put the files into tList -- a list of the file names
answer tList
end if
end mouseUp

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

Re: Unzip file and show it.

Post by Simon » Thu Feb 28, 2013 4:54 am

Just a quick check.
Do you have revzip selected in your standalone settings?

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

FireWorx
Posts: 362
Joined: Wed Sep 07, 2011 9:39 pm

Re: Unzip file and show it.

Post by FireWorx » Thu Feb 28, 2013 5:04 am

SO I rebuilt the stack and selected the rev zip inclusion in the general settings of the standalone builder.

I am still not getting the script to execute the line

revZipOpenArchive TempFile, "read"

as the
answer "I made it this far too" line never executes just below it. It freezes up I guess.

However an empty folder is now being created in the documents folder called "theContent" go figure?

Dave

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

Re: Unzip file and show it.

Post by Simon » Thu Feb 28, 2013 6:36 am

Hi Dave,
Built a stack for you to look at.
downtest.livecode.zip
LC 5x
(2.19 KiB) Downloaded 370 times
I think the trouble is revZipExtractItemToFile will not create folders.

Check out the scripts in both buttons, one downloads just zipped files the other a zipped folder.
Important to look at tList as you will see the first line is a folder.

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

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

Re: Unzip file and show it.

Post by Simon » Thu Feb 28, 2013 6:47 am

Rats!
Just tested it on Win and it wasn't as reliable:
unzip.zip
LC 5x
(1.8 KiB) Downloaded 373 times
I've added a downloadComplete message to the end of the libUrlDownloadToFile.
Much more robust.

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

FireWorx
Posts: 362
Joined: Wed Sep 07, 2011 9:39 pm

Re: Unzip file and show it.

Post by FireWorx » Thu Feb 28, 2013 8:34 pm

Thanks Simon,
I downloaded your stacks and they seem to work fine. I will carefully substitute my zipped file paths from my server into the script and give it a test run and report back tonight.
Thanks!
Dave

FireWorx
Posts: 362
Joined: Wed Sep 07, 2011 9:39 pm

Re: Unzip file and show it.

Post by FireWorx » Tue Mar 05, 2013 5:38 pm

Works great ! I built a progress bar to show the download time and the folder unzipping is very fast.
Thanks again!
Dave

jpatten
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 45
Joined: Tue May 06, 2008 11:24 pm

Re: Unzip file and show it.

Post by jpatten » Mon Nov 25, 2013 6:20 am

Hmmm...?

Does the unzip process still work in the example stack above? I downloaded it, did not make any changes, made sure the RevZip external was selected in the standalone settings, but when I test in simulator the zipped files do not unzip. The file gets downloaded, test.zip and testfolder.zip as they are listed, though they are not unzipped and deleted...

I have been futzing with the unzip process today and never was successful. Wondering if it's broke?

Thank you!

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

Re: Unzip file and show it.

Post by Simon » Mon Nov 25, 2013 7:16 am

Hi jpatten,
Which version of liveCode are you using?
Oh... and system stuff.

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

jpatten
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 45
Joined: Tue May 06, 2008 11:24 pm

Re: Unzip file and show it.

Post by jpatten » Mon Nov 25, 2013 7:38 am

Simon...

I'm running the latest version of LiveCode 6.1.3 and Version 6.0 (369.2) of the OS X simulator, OSX 10.9.

Thanks for taking a look!

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

Re: Unzip file and show it.

Post by Simon » Mon Nov 25, 2013 11:03 pm

Hi jpatten,
It appears that the callbackMessage is no longer being sent on mobile.

For a temp workaround you can re-enable that send in on downloadFiles

Code: Select all

send unZip to me in 50 milliseconds
I wouldn't use that method when releasing a product but you can use it for testing.

summary:
libUrlDownloadToFile does not send callbackMessage on mobile.

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

Post Reply