{"id":4448,"url":"https://github.com/mockingbot/react-native-zip-archive","last_synced_at":"2025-05-15T07:04:22.295Z","repository":{"id":1206822,"uuid":"41415993","full_name":"mockingbot/react-native-zip-archive","owner":"mockingbot","description":"Zip archive utility for react-native","archived":false,"fork":false,"pushed_at":"2025-02-22T00:51:22.000Z","size":1880,"stargazers_count":438,"open_issues_count":13,"forks_count":160,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-05-07T09:50:43.426Z","etag":null,"topics":["android","ios","react-native","unzip","zip","zip-assets"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mockingbot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-08-26T09:06:18.000Z","updated_at":"2025-05-04T11:59:25.000Z","dependencies_parsed_at":"2022-08-07T00:00:05.236Z","dependency_job_id":"f0e1a241-9ace-45f7-a8b4-e915781b5750","html_url":"https://github.com/mockingbot/react-native-zip-archive","commit_stats":{"total_commits":218,"total_committers":47,"mean_commits":4.638297872340425,"dds":"0.40825688073394495","last_synced_commit":"7ae2b49a210c0f4dac1e7627d47d0d4093c5f76b"},"previous_names":["plrthink/react-native-zip-archive"],"tags_count":58,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mockingbot%2Freact-native-zip-archive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mockingbot%2Freact-native-zip-archive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mockingbot%2Freact-native-zip-archive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mockingbot%2Freact-native-zip-archive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mockingbot","download_url":"https://codeload.github.com/mockingbot/react-native-zip-archive/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253805849,"owners_count":21967051,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","ios","react-native","unzip","zip","zip-assets"],"created_at":"2024-01-05T20:17:12.917Z","updated_at":"2025-05-15T07:04:22.247Z","avatar_url":"https://github.com/mockingbot.png","language":"Java","readme":"# React Native Zip Archive [![npm](https://img.shields.io/npm/v/react-native-zip-archive.svg)](https://www.npmjs.com/package/react-native-zip-archive)\n\nZip archive utility for react-native\n\n## Attention\n\nIn order to comply with the new privacy policy of the App Store on iOS, you need to upgrade react-native-zip-archive to version 7.0.0, which requires the deployment target to be iOS 15.5 or later.\n\n## For Expo Users\n\nThe only way to make this work with Expo is to create a [dev build](https://docs.expo.dev/workflow/overview/#development-builds), the expo go is not supported.\n\n## Compatibility\n\n| react-native version | react-native-zip-archive version |\n| --- | --- |\n| ^0.60 | ^5.0.0 |\n| ^0.58 | ^4.0.0 |\n| \u003c0.58 | ^3.0.0 |\n\n\n## Installation\n\n```bash\nnpm install react-native-zip-archive --save\n```\n\n\n## Linking\n\nFor iOS, run the command below in your app's root folder once the package has been installed\n\n````bash\ncd ./ios \u0026\u0026 pod install\n````\n\nFor Android, it's ready to go.\n\n\n## Usage\n\nimport it into your code\n\n```js\nimport { zip, unzip, unzipAssets, subscribe } from 'react-native-zip-archive'\n```\n\nyou may also want to use something like [react-native-fs](https://github.com/johanneslumpe/react-native-fs) to access the file system (check its repo for more information)\n\n```js\nimport { MainBundlePath, DocumentDirectoryPath } from 'react-native-fs'\n```\n\n\n## API\n\n**`zip(source: string | string[], target: string): Promise\u003cstring\u003e`**\n\n\u003e zip source to target\n\n***NOTE: the string version of source is for folder, the string[] version is for file, so if you want to zip a single file, use zip([file]) instead of zip(file)***\n\nExample\n\n```js\nconst targetPath = `${DocumentDirectoryPath}/myFile.zip`\nconst sourcePath = DocumentDirectoryPath\n\nzip(sourcePath, targetPath)\n.then((path) =\u003e {\n  console.log(`zip completed at ${path}`)\n})\n.catch((error) =\u003e {\n  console.error(error)\n})\n```\n\n**`zipWithPassword(source: string | string[], target: string, password: string, encryptionType: string): Promise\u003cstring\u003e`**\n\n\u003e zip source to target\n\n***NOTE: the string version of source is for folder, the string[] version is for file, so if you want to zip a single file, use zip([file]) instead of zip(file)***\n\n***NOTE: encryptionType is not supported on iOS yet, so it would be igonred on that platform.***\n\nExample\n\n```js\nconst targetPath = `${DocumentDirectoryPath}/myFile.zip`\nconst sourcePath = DocumentDirectoryPath\nconst password = 'password'\nconst encryptionType = 'STANDARD'; //possible values: AES-256, AES-128, STANDARD. default is STANDARD\n\nzipWithPassword(sourcePath, targetPath, password, encryptionType)\n.then((path) =\u003e {\n  console.log(`zip completed at ${path}`)\n})\n.catch((error) =\u003e {\n  console.error(error)\n})\n```\n\n**`unzip(source: string, target: string): Promise\u003cstring\u003e`**\n\n\u003e unzip from source to target\n\nExample\n\n```js\nconst sourcePath = `${DocumentDirectoryPath}/myFile.zip`\nconst targetPath = DocumentDirectoryPath\nconst charset = 'UTF-8'\n// charset possible values: UTF-8, GBK, US-ASCII and so on. If none was passed, default value is UTF-8\n\n\nunzip(sourcePath, targetPath, charset)\n.then((path) =\u003e {\n  console.log(`unzip completed at ${path}`)\n})\n.catch((error) =\u003e {\n  console.error(error)\n})\n```\n\n**`unzipWithPassword(source: string, target: string, password: string): Promise\u003cstring\u003e`**\n\n\u003e unzip from source to target\n\nExample\n\n```js\nconst sourcePath = `${DocumentDirectoryPath}/myFile.zip`\nconst targetPath = DocumentDirectoryPath\nconst password = 'password'\n\nunzipWithPassword(sourcePath, targetPath, password)\n.then((path) =\u003e {\n  console.log(`unzip completed at ${path}`)\n})\n.catch((error) =\u003e {\n  console.error(error)\n})\n```\n\n**`unzipAssets(assetPath: string, target: string): Promise\u003cstring\u003e`**\n\n\u003e unzip file from Android `assets` folder to target path\n\n***Note: Android only.***\n\n`assetPath` is the relative path to the file inside the pre-bundled assets folder, e.g. `folder/myFile.zip`. ***Do not pass an absolute directory.***\n\n```js\nconst assetPath = './myFile.zip'\nconst targetPath = DocumentDirectoryPath\n\nunzipAssets(assetPath, targetPath)\n.then((path) =\u003e {\n  console.log(`unzip completed at ${path}`)\n})\n.catch((error) =\u003e {\n  console.error(error)\n})\n```\n\n**`subscribe(callback: ({ progress: number, filePath: string }) =\u003e void): EmitterSubscription`**\n\n\u003e Subscribe to the progress callbacks. Useful for displaying a progress bar on your UI during the process.\n\nYour callback will be passed an object with the following fields:\n\n- `progress` (number)  a value from 0 to 1 representing the progress of the unzip method. 1 is completed.\n- `filePath` (string)  the zip file path of zipped or unzipped file.\n\n\n***Note: Remember to check the filename while processing progress, to be sure that the unzipped or zipped file is the right one, because the event is global.***\n\n***Note: Remember to unsubscribe! Run .remove() on the object returned by this method.***\n\n```js\ncomponentDidMount() {\n  this.zipProgress = subscribe(({ progress, filePath }) =\u003e {\n    // the filePath is always empty on iOS for zipping.\n    console.log(`progress: ${progress}\\nprocessed at: ${filePath}`)\n  })\n}\n\ncomponentWillUnmount() {\n  // Important: Unsubscribe from the progress events\n  this.zipProgress.remove()\n}\n```\n\n## Example App\nYou can use this repo, https://github.com/plrthink/RNZATestApp, for testing and contribution. For more information please refer to its README.\n\n\n## Related Projects\n\n- [ZipArchive](https://github.com/ZipArchive/ZipArchive)\n- [zip4j](https://github.com/srikanth-lingala/zip4j)\n\n---\n\n[![\"Buy Me A Coffee\"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/plrthink)\n","funding_links":["https://www.buymeacoffee.com/plrthink"],"categories":["Components","\u003ca name=\"OS-\u0026-System-\u0026-File-Manager:-Native-Modules\"\u003eOS, System \u0026 File Manager: Native Modules\u003c/a\u003e"],"sub_categories":["Utils \u0026 Infra"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmockingbot%2Freact-native-zip-archive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmockingbot%2Freact-native-zip-archive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmockingbot%2Freact-native-zip-archive/lists"}