mobilechromeapps / cordova-plugin-zip Goto Github PK
View Code? Open in Web Editor NEWZip plugin for Cordova apps
License: Other
Zip plugin for Cordova apps
License: Other
It would be convenient to be able to use the plugin through PhoneGap Build.
https://build.phonegap.com/plugins/add
error1
/Plugins/org.chromium.zip/Zip.m:13:9: Unknown type name 'CDVFilesystemURL'; did you mean 'CDVFileSystemType'?
" CDVFilesystemURL* url = [CDVFilesystemURL fileSystemURLWithString:urlString];"
error2
/Plugins/org.chromium.zip/Zip.m:13:34: Use of undeclared identifier 'CDVFilesystemURL'
" path = [filePlugin filesystemPathForURL:url];"
error 3
/Plugins/org.chromium.zip/Zip.m:14:28: No known instance method for selector 'filesystemPathForURL:'
any help ?
Hey,
I spent a LOT of time trying to figure out how to unzip a zip file included into my "assets" folder (Android)... because unzip() could never find my existing zip file... So the only solution is to copy the zip file from the assets into the device filesystem (i.e. cordova.file.externalCacheDirectory) with a
fileEntry.copyTo(dirEntry, 'name.zip', function(fileEntryCopy)...
Then it's working fine!
Please add a comment in the documentation about this requirement.
Any ideas?
Are you working in an abort function to cancel the unzip? Or is there already a way to do it?
I'm unzipping large files and I'd like the user to be able to cancel it without quitting the app.
The unzip function works fine. However, it doesnot work with the progress event. It provides the wrong value of loaded.
As filed in #43
Hey guys, we'd love to use this lib but need a LICENSE to do so!
Hi!
When I decompress a file in the event progress I have:
Math.round((progressEvent.loaded / progressEvent.total) * 100)
but at the end returns an incorrect value in loaded (stop at 87%):
progressEvent.total = 63467337
progressEvent.loaded = 44145467
it seems that everything works fine but the value loaded is incorrect
someone knows why?
thanks in advance
i find #60
So i download zip and it include my project.
but i can't unzip my file.
the error is Missing Command Error.
Is #60 's source working??
i use ngCordova
here is my code.
$cordovaZip .unzip( "ms-appdata:///local//example.zip" , "ms-appdata:///local//" ).then(function () { console.log('unzip success'); }, function () { console.log('error'); }, function (progressEvent) { console.log(progressEvent); });
Is it possible to unzip files in memory? Maybe choosing a tmp file as destination dir?
Many thanks
Entry in config.xml
<plugin name="cordova-plugin-zip" spec="https://github.com/MobileChromeApps/zip.git"/>
Error in console
https://github.com/MobileChromeApps/zip.git" checked out to git ref "master".
shell.js: internal error
Error: EXDEV: cross-device link not permitted, rename 'Users\AppData\Local\Temp\git\1479106416757\CONTRIBUTING.md' ->
l\build\plugins\cordova-plugin-zip\CONTRIBUTING.md'
at Error (native)
at Object.fs.renameSync (fs.js:681:18)
at C:\Program Files\nodejs\node_modules\cordova\node_modules\cordova-lib\node_modules\shelljs\src\mv.js:77:8
at Array.forEach (native)
at Object._mv (C:\Program Files\nodejs\node_modules\cordova\node_modules\cordova-lib\node_modules\shelljs\src\mv.js:53:11)
at Object.mv (C:\Program Files\nodejs\node_modules\cordova\node_modules\cordova-lib\node_modules\shelljs\src\common.js:186:23)
at C:\Program Files\nodejs\node_modules\cordova\node_modules\cordova-lib\src\plugman\util\plugins.js:53:19
at _fulfilled (C:\Program Files\nodejs\node_modules\cordova\node_modules\q\q.js:787:54)
at self.promiseDispatch.done (C:\Program Files\nodejs\node_modules\cordova\node_modules\q\q.js:816:30)
at Promise.promise.promiseDispatch (C:\Program Files\nodejs\node_modules\cordova\node_modules\q\q.js:749:13)
Is one other observe the issue with behavior like this.
Thanks
Hi,
[SOLVED]
I add the plugin to my project, however, there's no way I can access it.
I tried:
zip.unzip
window.zip...
cordova.plugins.zip...
window.plugins.zip...
cordova.require('zip')....
unfortunately, all return null. I have other plugins and they all work fine apart from this.
Could you please let me know how I can access this plugin after I add it to my project?
Thanks.
Apologies if this is mentioned already somewhere - just curious if there is some kind of onprogress event we can latch on to while the zip/unzip stuff does it's magic.
Because this plugin uses the Android logging class instead of the Cordova logging class the logging level cannot be controlled by the LogLevel
preference in config.xml.
Hello,
My brother and I want to develop a portable app for kids using cordova. The app will need some decompression in it. It would be the only platform plugin we would use.
Javascript may be too slow.
Do you know how to decompress in windows 8 through cordova ? Will MobileChromeApps/zip have a windows support (featured) ?
Thanks for developing.
I use iPhone4s(iOS7.1) and use this function of the plugin
zip.unzip();
it is not working
Error occurred during unzipping - failed to open zip file
I need full javascript example or tell me how to solve the problem
thanks!
When building a project for iOS , I am getting the following error:
Undefined symbols for architecture arm64: "_OBJC_CLASS_$_SSZipArchive", referenced from: objc-class-ref in ZipPlugin.o
Any ideas how to overcome that?
The plugin.xml
packageId is org.chromium.zip
but the Java source code uses package org.apache.cordova;
Simple fix, but I think there are some people writing extensions to this plugin and this is a breaking change.
Why? you don't good test before give download.i don't understand.Why it not work.
Does anyone else has performance issues? Unzipping a 100MB file on my S5 took about 10 minutes.
Any plans to update or relax the dependency version of the latest file plugin version (r1.2.0) ?
Given a project that is using the latest versions at present of the file and file transfer plugin:
$ cordova plugins list
org.apache.cordova.file 1.2.0 "File"
org.apache.cordova.file-transfer 0.4.4 "File Transfer"
org.chromium.zip 2.1.0 "Zip"
WARNING, broken dependency: plugin org.chromium.zip depends on org.apache.cordova.file 1.0.1 but installed version is 1.2.0
First of all, thanks for a great tool!
What happens if I try to unzip a zip file to a path that already contains files with the same name as those I unpack? Will they overwrite them or skip? I dosen't get any errors doing this, but it would be good to know what actually happens.
When I add the function
$cordovaZip
.unzip(
src, // https://github.com/MobileChromeApps/zip/blob/master/tests/tests.js#L32
dest // https://github.com/MobileChromeApps/zip/blob/master/tests/tests.js#L45
).then(function () {
elem.innerHTML = "success"
console.log('success');
}, function () {
console.log('error');
}, function (progressEvent) {
// https://github.com/MobileChromeApps/zip#usage
console.log(progressEvent);
I get the the following: Error: undefined is not an object (evaluating '$window.zip.unzip')
Are there additional packages that need to be installed to make $window defined?
Does this work in the simulator?
Can I use path like https://github.com/apache/cordova-plugin-file/blob/master/doc/index.md?
zip.unzip(cordova.file.documentsDirectory + 'source.zip', cordova.file.documentsDirectory + 'dir/', , []);
is working on iOS but not on Android. On Android, the callback argument was executed but progressCallback was not.
org.apache.cordova.file 1.3.1 "File"
org.apache.cordova.file-transfer 0.4.6 "File Transfer"
org.chromium.zip 2.1.0 "Zip"
When trying to run: cordova run ios
from the console, I get the following error:
** BUILD FAILED **
The following build commands failed:
CompileC build/Book\ Viewer.build/Debug-iphonesimulator/Book\ Viewer.build/Objects-normal/i386/Zip-91DF044CCBD185B3.o Book\ Viewer/Plugins/org.chromium.zip/Zip.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
Error: /Users/pedronetto/Sites/dev/book_viewer/platforms/ios/cordova/run: Command failed with exit code 65
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
Any ideas? Please let me know if more information is needed for a diagnosis. Thank you!
Hi, sorry can I test the plugin in a web navigator? or just in devices?
unzip error when file name contain Chinese name,
How do I solve this problem.
Below is a sample of the code, It runs perfectly fine on Android, however when run it on IOS I get the fallowing error "Error occurred during unzipping - failed to open zip file"
`var downloadsPath = cordova.file.dataDirectory +"downloads";
var testName = "testName";
var downloadedTestPath = cordova.file.dataDirectory +"downloadedTests";
$cordovaZip.unzip(downloadsPath + "/" + testName + ".zip", downloadedTestPath).then(function () {
console.log("Sanity Check - Unzip Success");
})`
Hi,
The package org.apache.cordova.api don't exists in Cordova/Phonegap 3.0.0.
CallbackContext and CordovaPlugin classes were moved to org.apache.cordova.
import org.apache.cordova.api.CallbackContext;
import org.apache.cordova.api.CordovaPlugin;
The above code causes an error, should be changed by the following code:
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
I am unzipping "content.zip" and it gets unzipped as "content".
Second time when I unzip an updated "content.zip", I dont find "content" updated with the new data.
Instead "content" still has the old data.
Where is the new "content.zip" unzipped?
Or during Unzip can we replace the old unzipped Content?
I get the following when trying to build an app for iOS. Building for Android works fine.
The app in question is currently on [email protected] with the following plugin dependencies:
Any idea what is going on there?
$ cordova build ios
Generating config.xml from defaults for platform "ios"
Preparing ios project
Compiling app on platform "ios" via command "/Users/zarko/app/cordova-wrapper/platforms/ios/cordova/build"
Error: An error occurred while building the ios project.2014-02-25 10:46:08.483 xcodebuild[13775:4603] DeveloperPortal: Using pre-existing current store at URL (file:///Users/zarko/Library/Developer/Xcode/DeveloperPortal%205.0.2.db).
2014-02-25 10:46:09.771 xcodebuild[13787:4007] DeveloperPortal: Using pre-existing current store at URL (file:///Users/zarko/Library/Developer/Xcode/DeveloperPortal%205.0.2.db).
2014-02-25 10:46:11.150 xcodebuild[13803:4403] DeveloperPortal: Using pre-existing current store at URL (file:///Users/zarko/Library/Developer/Xcode/DeveloperPortal%205.0.2.db).
** BUILD FAILED **
The following build commands failed:
CompileC build/App.build/Debug-iphoneos/App.build/Objects-normal/armv7/Zip-7206AAEE14DAC4B1.o App/Plugins/org.chromium.zip/Zip.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
** BUILD FAILED **
The following build commands failed:
CompileC build/App.build/Debug-iphonesimulator/App.build/Objects-normal/i386/Zip-7206AAEE14DAC4B1.o App/Plugins/org.chromium.zip/Zip.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
at ChildProcess.<anonymous> (/usr/local/lib/node_modules/cordova/src/compile.js:65:22)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
When i try to build the project i get the following error
I know it has something to do with the imports just can't figure out which.
Undefined symbols for architecture x86_64:
"_crc32", referenced from:
_zipWriteInFileInZip in zip-E26E9335CB84AC5A.o
_unzReadCurrentFile in unzip.o
"_deflate", referenced from:
_zipWriteInFileInZip in zip-E26E9335CB84AC5A.o
_zipCloseFileInZipRaw64 in zip-E26E9335CB84AC5A.o
"_deflateEnd", referenced from:
_zipCloseFileInZipRaw64 in zip-E26E9335CB84AC5A.o
"_deflateInit2_", referenced from:
_zipOpenNewFileInZip4_64 in zip-E26E9335CB84AC5A.o
"_get_crc_table", referenced from:
_zipOpenNewFileInZip4_64 in zip-E26E9335CB84AC5A.o
_unzOpenCurrentFile3 in unzip.o
"_inflate", referenced from:
_unzReadCurrentFile in unzip.o
"_inflateEnd", referenced from:
_unzCloseCurrentFile in unzip.o
"_inflateInit2_", referenced from:
_unzOpenCurrentFile3 in unzip.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Hi,
I'm getting the following error for IOS Platform when using the plugin through build.phonegap.com
Error - A plugin in your app does not support the compulsory arm64 (64-bit support) architecture.
Any idea why is this happening?
Regards,
Farhan
Add a flatten option: flatten zipped content on Unzip, by ignore internal directory structure when unzipping.
Thanks for creating this awesome plugin which is used in my android app.
But I found the directory structure in zip file in the windows format is not parsed correctly on some device. For example, on the tablet, structure in zip file: com.ea.game.silverback_row\com.ea.game.silverback_row.obb (folder/filename) is parsed as a file com.ea.game.silverback_row\com.ea.game.silverback_row.obb (filename).
I fixed this issue by adding the following line in your source code Line 120:
compressedName=compressedName.replace("", "/"); //replace "" with "/" if exists.
The org.apache.cordova.file dependency recently changed to cordova-plugin-file, and now we get an error when cordova install cordova-plugin-zip, because cordova-plugin-file is not available on http://registry.cordova.io/ (as it is not released yet, see https://issues.apache.org/jira/browse/CB-8806).
It might also produce conflicts with other Apache plugins depending on org.apache.cordova.file (like like org.apache.cordova.file-transfer or org.apache.cordova.media).
I wrote an answer on stackoverflow about that: http://stackoverflow.com/questions/30302647/error-404-cordova-plugin-file-when-trying-to-install-cordova-plugin-zip-for-ios/30344258#30344258, but maybe it would be helpful to mention it on the README until org.apache.cordova.file v2 is released.
Hi,
I'm unziping a very large file with almost 10.000 files into my SD Cart, the unzip starts smootly but when reach about 60% return this error.
E/Zip ( 5633): An error occurred while unzipping.
E/Zip ( 5633): java.io.IOException: open failed: ENOSPC (No space left on device)
E/Zip ( 5633): at java.io.File.createNewFile(File.java:950)
E/Zip ( 5633): at org.apache.cordova.Zip.unzipSync(Zip.java:130)
E/Zip ( 5633): at org.apache.cordova.Zip.access$000(Zip.java:23)
E/Zip ( 5633): at org.apache.cordova.Zip$1.run(Zip.java:39)
E/Zip ( 5633): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/Zip ( 5633): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/Zip ( 5633): at java.lang.Thread.run(Thread.java:841)
E/Zip ( 5633): Caused by: libcore.io.ErrnoException: open failed: ENOSPC (No space left on device)
E/Zip ( 5633): at libcore.io.Posix.open(Native Method)
E/Zip ( 5633): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
E/Zip ( 5633): at java.io.File.createNewFile(File.java:943)
E/Zip ( 5633): ... 6 more
This is strange because the size (unpacked) of all files is about 70mb and I have near 2.5GB avaliable on SD.
Also, when this occurs I can't execute the unzip again, I need to kill my app and launch again, seems that the queue is not reseted or other proccess stills hang
Hey guys, great job you're doing here! I'd like to ask if the plugin does not currently handle sub-directories or if maybe I'm doing something wrong.
The files in the root directory inside the zip come out ok, but the only sub-directory I have returns an error.
Cheers, rock on!
I have a problem with files bigger than 10mb which can lead to a memory warnings till a signal 9 which kills the complete app. Is there any maximum you know?
Hi guys,
Thanks for sharing this great work, and especially thanks for the hard work. I've successfully downloaded and installed your plugin for a Cordova project on iOS. However, I get the following error every time I try and unzip a file : Error occurred during unzipping - failed to open zip file (sadly, that is the only error output I get, so it is little to go on)
I have double checked the paths (absolute paths to system Documents directory where I download files using FileTransfer), the zip file (successfully unzipped on my machine), the size and type of the zipped file (txt, json, sqlite…) but I keep getting the error.
Tested on iOS 7.0.6 on an iPhone 4S and iPhone simulators (all).
Could this be a bug or am I doing something wrong ?
I've successfully downloaded and installed your plugin on iOS but whenever I try to unzip it gives me the following error: "Error occurred during unzipping - failed to open zip file". This is what I've done so far;
I successfully downloaded my zip file using the cordova file transfer plugin and my code looks like this:
zip.unzip("file:///var/mobile/Containers/Data/Application/21347191-2DFA-4E0D-A6F6-54C25B0A4F1F/Library/files/file.zip", fileEntry.toURL(), function () {
alert('success');
});
The source URL is where my zip file rests. I'm working on iOS 9.3.4.
Is there something i'm doing wrong?
This plugin is missing the Windows and Windows phone implementation that would help port the Cordova based applications directly to Windows 8.1+ devices.
This is a request to enhance this plugin to support the Windows platform as well.
I have got some problems, where the unzipping fails some times. I think it might be because I download two files, and when they're finished they unzip instantly.
I think it's because they might be unzipping concurrently and therefore failing.
Is it possible to unzip two files at the same time on Android and iOS using this plugin?
i use jailbreaken iPhone and use this function
zip.unzip('/www', '/www/1', function(){
console.log('All done');
});
not working
Error occurred during unzipping - failed to open zip file
i need full javascript example
thanks
Gday!
I added the plugin and attempted to use it in one of my source.js files and am getting:
2014-05-27 15:39:55.691 Flows-Test[7064:60b] CDVPlugin class Zip (pluginName: Zip) does not exist.
2014-05-27 15:39:55.692 Flows-Test[7064:60b] ERROR: Plugin 'Zip' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
2014-05-27 15:39:55.692 Flows-Test[7064:60b] -[CDVCommandQueue executePending] [Line 158] FAILED pluginJSON = [
"Zip612661074",
"Zip",
"unzip",
[
"reports.zip",
"cdvfile://localhost/persistent/"
]
]
I looked high and low and the plug in looks like it installed no problem at all. However I haven't found anything else with this message. Sorry to ask more a support question but could there be a problem with cordova 3.4?
Hi, I've noticed that the plugin was extracting files with the wrong path separator.
The output directory is cordova.file.dataDirectory and the plugin extracted the files to ../media\text\text.txt instead of ../media/text/text.txt so I have errors reading these files.
I temporary fix this by replacing the path separator in the src file:
(outputDirectory + compressedName).replace('\\', '/')
In addition, any chance to add a check for the already extracted files? It extracts all the files every time I call the zip method.
Best regards.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.