https://github.com/appcelerator-modules/ti.compression
Compress your files to reduce storage
https://github.com/appcelerator-modules/ti.compression
titanium-module
Last synced: 4 months ago
JSON representation
Compress your files to reduce storage
- Host: GitHub
- URL: https://github.com/appcelerator-modules/ti.compression
- Owner: tidev
- License: other
- Created: 2014-08-07T16:15:52.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2024-03-06T21:43:56.000Z (over 1 year ago)
- Last Synced: 2025-02-26T23:03:21.269Z (4 months ago)
- Topics: titanium-module
- Language: C
- Homepage:
- Size: 6.59 MB
- Stars: 29
- Watchers: 23
- Forks: 20
- Open Issues: 34
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Ti.Compression Module
## Description
Lets you zip and unzip files.
## Getting Started
View the [Using Titanium Modules](http://docs.appcelerator.com/platform/latest/#!/guide/Using_Titanium_Modules) document for instructions on getting
started with using this module in your application.## Accessing the Ti.Compression Module
To access this module from JavaScript, you would do the following:
```js
var Compression = require('ti.compression');
```## Functions
### string zip(string archiveFile, string[] fileArray)
Compresses all of the files you pass in "fileArray" to the specified "archiveFile".
#### Arguments
* string archiveFile: The path to the archive file to create
* string[] fileArray: An array of files to compressReturns the string "success" if the operation succeeded, or an error message if something went wrong.
### string unzip(string destinationFolder, string archiveFile, bool overwrite)
Extracts the files in the archive file into the destination folder, optionally overriding existing files.
#### Arguments
* string destinationFolder: The destination folder for the extracted files
* string archiveFile: The path to an existing compressed archive file
* bool overwrite: Indicates if existing files should be overwrittenReturns the string "success" if the operation succeeded, or an error message if something went wrong.
## Usage
To create an archive:
```js
var result = Ti.Compression.zip('test.zip', [ 'a.dat', 'b.dat', 'c.dat' ];
```To extract an archive:
```js
var result = Ti.Compression.unzip(Ti.Filesystem.applicationDataDirectory + 'data', 'test.zip', true);
```See example for more details.
## zip Parameter
Android:
* filename:String, files:Array, options: Object [compression: Compression.BEST_SPEED | Compression.DEFAULT_COMPRESSION | Compression.NO_COMPRESSION]iOS:
* filename:String, files:Array## Create demo files
Create demo files
good compression (no content)
```bash
truncate -s 5M file1.dat
```Bad compression (random content)
```bash
dd if=/dev/urandom of=file1 bs=5M count=1
```## Author
Clint Tredway
## License
Copyright(c) 2010-present by Axway Appcelerator. All Rights Reserved. Please see the LICENSE file included in the distribution for further details.