ZipFile — Mobile Titanium module (iPhone)
I started develop titanium module that add functions to working with zip files. (ZipArchive wrapper) Fist version has only one method to extracts files from zip archive.But I plan to add new functionality soon. For more information please visit github repo
Example:
//app.js: download zip from DropBox to Documents folder
// and extact file to Documents folder
Titanium.UI.setBackgroundColor('#000');
var win1 = Titanium.UI.createWindow({
title:'ZipFile test',
backgroundColor:'#fff'
});
win1.open();
var xhr = Titanium.Network.createHTTPClient();
xhr.onload = function()
{
var f = Ti.Filesystem.getFile(
Ti.Filesystem.applicationDataDirectory,
'test.zip'
);
f.write(this.responseData);
Ti.API.log('INFO',Ti.Filesystem.applicationDataDirectory);
Ti.ZipFile.extract(
Ti.Filesystem.applicationDataDirectory+'/test.zip',
Ti.Filesystem.applicationDataDirectory
);
};
xhr.open('GET','http://dl.dropbox.com/u/1400234/test.zip');
xhr.send();
30 Answers
-
So that people dont have to dig through comments, here's the compiled source for 0.1.21:
http://kosso.co.uk/stuff/zipfile-iphone-0.1.21.zip
-
I have made the android version (it only extracts for the moment).
It is available on GitHub : androzip -
var appDir = Ti.Network.decodeURIComponent(Ti.Filesystem.applicationDataDirectory).replace('file://localhost', ''); zipfile.extract(appDir + 'test.zip', appDir);
this can fixed the "Can't find zipfile"
[DEBUG] zip opened [DEBUG] file unzipped
-
I downloaded the latest build (0.1.21), put it in the right path, register it in tiapp.xml and my App says, the module is loaded
[INFO] [object ZipfileModule] loaded [INFO] module is => [object ZipfileModule]
BUT…..
Then my zipped File is correctly loaded and nothing happens, it (the module) doesn't unzip the zipfile. What is my mistake?
Sorry for my English an the question, I'm a Ti.Beginner.
function loadunzip(){ var xhr = Titanium.Network.createHTTPClient(); xhr.onload = function() { var f = Ti.Filesystem.getFile(myDir.nativePath,'bilder02.zip'); f.write(this.responseData); Ti.API.log('INFO',myDir.nativePath); Ti.ZipFile.extract(myDir.nativePath +'/bilder02.zip',myDir.nativePath); }; xhr.open('GET', path+'bilder02.zip'); xhr.send(); }; loadunzip();
-
Help: I can't seem to get Zipfile installed.
I get
Script Error = Couldn't find module: zipfile.
I have
<modules> <module platform="iphone" version="0.1.18">zipfile</module> </modules>
in my tiapp.xml
and the files are located in /Library/Application Support/Titanium/Modules/iphone/zipfile/0.1.18
Using the example code from the site, just trying to load the module at this time. Thanks to the author for the hard work, looking forward to working with it.
-
It now allows the creation as well. However, notice that it is iOS specific. It does not have a similar android module included.
-
Awesome Work, tested it out and works extremely nice.
simple and easy to use!.If you want can you explain your work a bit?
I'm trying to create a module myself for numerous things later, but I seem to get really confused about how the setup in modules is.
I mean my test module i am trying to make something draggable using touch events,
But how do go about this..everytime I get somewhere and seems to work, the build fails..
I'm probally doing something wrong here, like declaring function or arguments in the wrong file etc.Anyway we need someone with this kind of experience to create a sort of tut/doc in which you create a simple view or something that way more people can try and make modules
-
Hey - just curious if anyone has tried this with the latest Mobile build of Titanium? It appears to be detecting the module OK - but failing on completing the build.
-
I get no "Detecting third-party module:"
in my tiapp.xml I wrote "<module version="0.1.18">zipfile</module>", but Titanium didn't find the module.
any ideas?
-
Hi there, I'm desperately trying to get this module working but without luck.
Every time I add this to my project it just won't run.I'm on mac, using TiStudio with 1.7.1 sdk, module is located in
/Volumes/Mac/Library/Application Support/Titanium/modules/iphone/zipfile/0.1.21/
, in tiapp.xml I have this<modules> <module version="0.1.21">zipfile</module> </modules>
but app just crashes before executing.
With this log:[INFO] One moment, building ... [DEBUG] Detecting modules in /Users/Master/Documents/Titanium Studio Workspace/virtualnezahorie/modules [DEBUG] Detecting modules in /Library/Application Support/Titanium/modules [DEBUG] Detected module for iphone: zipfile 0.1.21 @ /Library/Application Support/Titanium/modules/iphone/zipfile/0.1.21 [DEBUG] Looking for Titanium Module id: zipfile, version: 0.1.21, platform: <any platform> [INFO] Detected third-party module: zipfile/0.1.21 [INFO] Titanium SDK version: 1.7.1 [INFO] iPhone Device family: iphone [INFO] iPhone SDK version: 4.3 [INFO] iPhone simulated device: iphone [DEBUG] executing command: /usr/bin/killall iPhone Simulator [DEBUG] No matching processes belonging to you were found [DEBUG] finding old log files [DEBUG] executing command: mdfind -onlyin /Users/Master/Library/Application Support/iPhone Simulator/4.3 -name 48c986ed-31be-48ae-982a-40c99b21e2ea.log [INFO] Launching application in Simulator [INFO] Launched application in Simulator (14.22 seconds) [DEBUG] App Spec: <DTiPhoneSimulatorApplicationSpecifier 0x100303b50> specified by path /Users/Master/Documents/Titanium Studio Workspace/virtualnezahorie/build/iphone/build/Debug-iphonesimulator/virtualnezahorie.app [DEBUG] SDK Root: <DTiPhoneSimulatorSystemRoot 0x1003023f0> path=/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk version=4.3 name=Simulator - iOS 4.3 [DEBUG] using device family iphone [DEBUG] Session could not be started: Error Domain=DTiPhoneSimulatorErrorDomain Code=1 UserInfo=0x10011e7e0 "Unknown error." [INFO] Application has exited from Simulator
-
Where do I download the 0.1.21 version? I can only find versions 0.1.18 and 0.1.17 on github.. Maybe I am looking at the wrong place. Can someone help me find it?
-
Was functionality ever added to create zip files on Android with this module? I can't find it in the notes.
-
Hello, when i try to build the build.py i get the folowing error:
The following build commands failed:
CompileC build/ZipFile.build/Release-iphoneos/zipfile.build/Objects-normal/armv6/ZipfileModule.o Classes/ZipfileModule.m normal armv6 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
xcodebuild faileddoes anybody knows what this means?
-
Is there a newer compiled source that 0.1.21.zip?
I noticed that there have been a few new commits on github.
-
Thanks for the module. It works perfectly for what I need it to do. Is there something to listen for when zipfile is done unzipping?
-
Thanks for the module. It works perfectly for what I need it to do. Is there something to listen for when zipfile is done unzipping?
-
Upgraded my xcode and titanium now zipfile module seems to crash my app.. Pls help me asap.. it affects all my apps since I have used it to extract files from server..
-
Thanks for sharing this - it's something I'd planned to look into in the future. You didn't touch the license file though - are you allowing us to use this in our commercial apps?
-
this is great!
one problem,
http://github.com/TermiT/ZipFile/blob/master/Classes/ZipFileModule.m#L103
on line #103 - you should not release the filemanager or you'll get a crasher. the filemanager instance returned is already autoreleased so you don't need to release.
-
ok, I build it and now I got a zipfile…. what now?
I copied the extracted module folder to /Library/Application Support/Titanium
but I can't use it…. :-( -
ok, I build it and now I got a zipfile…. what now?
I copied the extracted module folder to /Library/Application Support/Titanium
but I can't use it…. :-( -
Thanks for sharing - this is quite helpful.
One quick note/question - my compile time for my app without the Zip module is clocked at 0.8 secs, but with the module it slows to 27 secs. Any idea why it takes so much longer to compile with the module? -
Here's an updated version which adds the ability to create zips. Hopefully the poster will merge this when he gets a chance.
http://github.com/dae/ZipFile/tree/
-
Sweet! This should come in handy for an apps that require file downloads!
-
This is fantastic - thank you.
Are there any plans (or perhaps support, if I'm missing something) on supporting tar or gzip? Standard zip files work fine, however a .gz file throws the following console output –
[DEBUG] [object ZipFileModule] loaded [DEBUG] can't open zip [DEBUG] can't open zip ...again and again
-
I just came across this module, and it should be perfect for my needs. A few questions:
On the downloads at github, the 0.1.18 folder structure is different than the 0.1.17 structure. The .17 is prebuilt with the folders to drop into place per the Readme file. The .18 appears to need to be compiled. For newbies like myself, where / how do you "Just run ./build.py" ?
Since .17 is already built, I am trying to use that in a project. In the Ti console window it never gets past "Performing clean build". It says it detected third-party module: zipfile/0.1.17 and the "Performing full rebuild…" then says "Performing clean build" and just appears to hang.
I have tried using Ti SDK 1.4.2 and 1.5.0 beta.
I can only get it to do the above if I close Ti, empty the project build/iphone folder, and retry. If I don't do that, it hangs at "iPhone SDK version: 4.1"
What am I doing wrong that I cannot build even for the emulator?
-
does this allow the creation of .zip files as well or just the unzipping of them?
-
It now allows the creation as well. However, notice that it is iOS specific. It does not have a similar android module included.
-
It now allows the creation as well. However, notice that it is iOS specific. It does not have a similar android module included.
-
Thanks for sharing this - it's something I'd planned to look into in the future. You didn't touch the license file though - are you allowing us to use this in our commercial apps?