Giter VIP home page Giter VIP logo

react-native-zip-archive's Introduction

React Native Zip Archive npm

Zip archive utility for react-native

Compatibility

react-native version react-native-zip-archive version
^0.60 ^5.0.0
^0.58 ^4.0.0
<0.58 ^3.0.0

Installation

npm install react-native-zip-archive --save

Linking

For iOS, run the command below in you app's root folder once the package has been installed

cd ./ios && pod install

For Android, it's ready to go.

Usage

import it into your code

import { zip, unzip, unzipAssets, subscribe } from 'react-native-zip-archive'

you may also want to use something like react-native-fs to access the file system (check its repo for more information)

import { MainBundlePath, DocumentDirectoryPath } from 'react-native-fs'

API

zip(source: string | string[], target: string): Promise<string>

zip source to target

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)

Example

const targetPath = `${DocumentDirectoryPath}/myFile.zip`
const sourcePath = DocumentDirectoryPath

zip(sourcePath, targetPath)
.then((path) => {
  console.log(`zip completed at ${path}`)
})
.catch((error) => {
  console.error(error)
})

zipWithPassword(source: string | string[], target: string, password: string, encryptionType: string): Promise<string>

zip source to target

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)

NOTE: encryptionType is not supported on iOS yet, so it would be igonred on that platform.

Example

const targetPath = `${DocumentDirectoryPath}/myFile.zip`
const sourcePath = DocumentDirectoryPath
const password = 'password'
const encryptionType = 'STANDARD'; //possible values: AES-256, AES-128, STANDARD. default is STANDARD

zipWithPassword(sourcePath, targetPath, password, encryptionType)
.then((path) => {
  console.log(`zip completed at ${path}`)
})
.catch((error) => {
  console.error(error)
})

unzip(source: string, target: string): Promise<string>

unzip from source to target

Example

const sourcePath = `${DocumentDirectoryPath}/myFile.zip`
const targetPath = DocumentDirectoryPath
const charset = 'UTF-8'
// charset possible values: UTF-8, GBK, US-ASCII and so on. If none was passed, default value is UTF-8


unzip(sourcePath, targetPath, charset)
.then((path) => {
  console.log(`unzip completed at ${path}`)
})
.catch((error) => {
  console.error(error)
})

unzipWithPassword(source: string, target: string, password: string): Promise<string>

unzip from source to target

Example

const sourcePath = `${DocumentDirectoryPath}/myFile.zip`
const targetPath = DocumentDirectoryPath
const password = 'password'

unzipWithPassword(sourcePath, targetPath, password)
.then((path) => {
  console.log(`unzip completed at ${path}`)
})
.catch((error) => {
  console.error(error)
})

unzipAssets(assetPath: string, target: string): Promise<string>

unzip file from Android assets folder to target path

Note: Android only.

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.

const assetPath = './myFile.zip'
const targetPath = DocumentDirectoryPath

unzipAssets(assetPath, targetPath)
.then((path) => {
  console.log(`unzip completed at ${path}`)
})
.catch((error) => {
  console.error(error)
})

subscribe(callback: ({ progress: number, filePath: string }) => void): EmitterSubscription

Subscribe to the progress callbacks. Useful for displaying a progress bar on your UI during the process.

Your callback will be passed an object with the following fields:

  • progress (number) a value from 0 to 1 representing the progress of the unzip method. 1 is completed.
  • filePath (string) the zip file path of zipped or unzipped file.

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.

Note: Remember to unsubscribe! Run .remove() on the object returned by this method.

componentDidMount() {
  this.zipProgress = subscribe(({ progress, filePath }) => {
    // the filePath is always empty on iOS for zipping.
    console.log(`progress: ${progress}\nprocessed at: ${filePath}`)
  })
}

componentWillUnmount() {
  // Important: Unsubscribe from the progress events
  this.zipProgress.remove()
}

Example App

You can use this repo, https://github.com/plrthink/RNZATestApp, for testing and contribution. For more information please refer to its README.

Related Projects


"Buy Me A Coffee"

react-native-zip-archive's People

Contributors

almostintuitive avatar bdtren avatar benvium avatar berndschrooten avatar brystfire08 avatar buthrakaur avatar chirag04 avatar danilocanalle avatar hengkx avatar itinance avatar javache avatar johnwilliamforcier-spiria avatar jon-moreira avatar kenyuwin avatar kurtsergey avatar light-of-king avatar lmvco avatar macrozone avatar mars-lan avatar mopx avatar moweex-mobile avatar plrthink avatar prometee avatar qiyanlong avatar randy-yang avatar ratson avatar rbnquintero avatar sunnylqm avatar yaohuiji avatar zimo888 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-zip-archive's Issues

we need some tests

Since this package is becoming more and more popular, thanks to the community, I think we need some test to make it more reliable.

ideas and PRs are welcome~

cannot extract .zip file on android

I ran into this exact problem today:
https://stackoverflow.com/questions/15738312/how-to-fix-org-apache-commons-compress-archivers-zip-unsupportedzipfeatureexcept

java.util.zip.ZipException: only DEFLATED entries can have EXT descriptor

I saw no obvious way to resolve this using the java.util.zip package, so I just used the org.apache.commons.compress.archivers.zip.ZipArchiveInputStream class instead as a hack workaround. I documented the neccessary changes in my branch here:
mikestaub@f8af246

I am creating this issue in case others run into the same problem, or that you know the proper solution.

RCTBridgeModule.h file not found

Hello Team,

I'm using react native version 0.30, but I'm facing RCTBridgeModule.h file not found, please suggest me what should I do.

File fails to unzip with FileNotFoundException on Android

I am attempting to unzip an archive in Android with the following directory structure

A
-B
--File1.txt

When unzipping I get a FileNotFoundException: "open failed: ENOENT (No such file or directory)" when RNZipArchiveModule::extractFile is called for the first time.

I have found that when it is stepping through the entries in RNZipArchiveModule::unzipStream the following entries come in:
"A/B/" - directory doesn't get made
"A/B/File1.txt" - throws exception (Because "A/B" isn't there)

Note that I am given this archive and do not have control on its creation (but I can extract it with other zip programs, so it should be valid). When I attempt to create my own archive with same structure, everything works and I get the following entries:
A/
A/B/
A/B/File1.txt

In terms of fixes, I have found that similar to 96d62c7, also changing line 94 to mkdirs makes the first case work as the 2 directories can be created at once.

[Android] Couldn't zip on RN 0.46.4

I get this error when trying to zip a folder on Android 7.0 (Galaxy 8) (Update: same on simulator Android 6.0)

Error: Couldn't zip /data/user/0/com.myapp/files/backup.zip
    at createErrorFromErrorData (NativeModules.js:121)
    at NativeModules.js:78
    at MessageQueue.__invokeCallback (MessageQueue.js:301)
    at MessageQueue.js:118
    at MessageQueue.__guard (MessageQueue.js:228)
    at MessageQueue.invokeCallbackAndReturnFlushedQueue (MessageQueue.js:117)
    at debuggerWorker.js:71

Unzip works fine though...!

I'm running latest master commit.
All worked fine on RN 0.43.3, but this happens on RN 0.46.4

iOS zip and unzip work fine too btw!

Update npm package

Update npm package to match master and be compatible with RN 0.47

As a workaround I'm using

"react-native-zip-archive": "github:mockingbot/react-native-zip-archive#c0bc574e6244a9a9bbd489c4a42170674af389ad"

duplicate symbol _OBJC_IVAR_$_SSZipArchive._zip

If you're using other react native package which also includes in SSZipArchive like react-native-code-push, you may face this issue when trying to build your app.

The problem is straightforward. Since we're both want to link some file in SSZipArchive so the linker would fail.

I'm trying to solve this issue. Any guide would be thankful.

unable to unzip in ios using native base kitchen sink template

error log --
[info][tid:com.facebook.react.JavaScript] file:///Users/nepaldigital/Library/Developer/CoreSimulator/Devices/F1729D4C-347F-42EA-9198-8DF061204525/data/Containers/Bundle/Application/BEA0BB92-D9A5-446F-8B2B-1FCC388BB983/NativebaseKitchenSink.app/751.zip
[info][tid:com.facebook.react.JavaScript] { [Error: unable to unzip]
line: 2807,
column: 24,
sourceURL: 'http://192.168.1.53.xip.io:8081/index.ios.bundle?platform=ios&dev=true&minify=false',
framesToPop: 1,
code: 'unzip_error',
domain: 'RCTErrorDomain',
userInfo: null,
nativeStackIOS:
[ '0 NativebaseKitchenSink 0x0016125f RCTJSErrorFromCodeMessageAndNSError + 104',
'1 NativebaseKitchenSink 0x000f6099 __41-[RCTModuleMethod processMethodSignature]_block_invoke_2.224 + 96',
'2 NativebaseKitchenSink 0x0023e8db -[RNZipArchive unzip:destinationPath:resolver:rejecter:] + 310',
'3 CoreFoundation 0x24f5c534 + 68',
'4 CoreFoundation 0x24e8293d + 292',
'5 CoreFoundation 0x24e863b7 + 50',
'6 NativebaseKitchenSink 0x000f70e7 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 1658',
'7 NativebaseKitchenSink 0x00146c7b -[RCTBatchedBridge callNativeModule:method:params:] + 734',
'8 NativebaseKitchenSink 0x00146169 __33-[RCTBatchedBridge handleBuffer:]_block_invoke.477 + 1206',
'9 libdispatch.dylib 0x004f2b7f _dispatch_call_block_and_release + 10',
'10 libdispatch.dylib 0x004fd493 _dispatch_queue_drain + 2014',
'11 libdispatch.dylib 0x004f5de1 _dispatch_queue_invoke + 284',
'12 libdispatch.dylib 0x004feecf _dispatch_root_queue_drain + 1790',
'13 libdispatch.dylib 0x004fe7cf _dispatch_worker_thread3 + 102',
'14 libsystem_pthread.dylib 0x24c89b29 _pthread_wqthread + 1024',
'15 libsystem_pthread.dylib 0x24c89718 start_wqthread + 8' ] }

undefined is not an object (evaluating 'RNZipArchive.unzip')

I'm having an issue when I import the {Unzip} from the library.
The error is the one described in the title.
I've been trying to find another solution than the one already posted here and closed because it wasn't helping, I've tried everything I have in mind and it just won't work in Android. It works fine in iOS.

I'm using:
"react-native": "0.43.3",
"react-native-zip-archive": "^1.1.1"

Can't build after upgrade React Native to 0.45

Hi all,

After I update my project to React Native 0.45, I have trouble with RNZipArchive, I can't build it because it alert "/node_modules/react-native/React/Base/RCTBridgeModule.h:12:9: 'React/RCTDefines.h' file not found"

Any ideas to fix or I must downgrade React Native ver?

Thanks,

Compile issue with RN 0.41

When compiling the app with RN 0.41, it fails with this error:

clang: error: no such file or directory: '/myapp/node_modules/react-native-zip-archive/ios/RNZipArchive.m'
clang: error: no input files

It was fixed after moving some files around in this package, RNZipArchive.m and RNZipArchive.h need to be directly in ios/. After this the build succeeded again. I'm not sure if this is the correct way to fix it, but I'll submit a PR.

Issue while unzipping on IOS

I get the following error:

Error: unable to unzip
at createErrorFromErrorData (NativeModules.js:116)
at NativeModules.js:79
at MessageQueue.__invokeCallback (MessageQueue.js:288)
at MessageQueue.js:127
at guard (MessageQueue.js:46)
at MessageQueue.invokeCallbackAndReturnFlushedQueue (MessageQueue.js:126)
at debuggerWorker.js:71

Unzip on Android

Unzip on Android

it can not unzip on android.
open failed: enoent (no such file or directory)

Make it work with rnpm

rnpm is pretty much becoming the de facto react-native 'native' module linker, and it works with almost all modules I tried - react-native-zip-archive was the first one where it didn't.

It seems that linking libz manually fixed it. I'm not too familiar with native iOS development but maybe something to look at?

Error Not Being Raised for Non Existent Zip

Tis is calling the then rather than catch where the specified file does not exist:

   ZipArchive.unzip(RNFS.CachesDirectoryPath + '/XXXXX.zip', RNFS.CachesDirectoryPath + '/YYYY')
      .then((o) => {
        alert('o: ' + o)
      })
      .catch((error) => {
        alert('E: ' + error)
      });

Doesn't work with React Native 0.46.4

:react-native-zip-archive:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.). /Users/mark/Dev/drops-react-native/node_modules/react-native-zip-archive/android/src/main/java/com/rnziparchive/RNZipArchivePackage.java:11: error: RNZipArchivePackage is not abstract and does not override abstract method createJSModules() in ReactPackage public class RNZipArchivePackage implements ReactPackage { ^ 1 error :react-native-zip-archive:compileReleaseJavaWithJavac FAILED

The library compiled fine with RN 0.45.1

Related issue:
software-mansion/react-native-svg#412

cannot use async/await

Hello. Thank you for this wonderful library. I encountered an issue where I've used the unzipping and zipping commands using async/await and they don't work as expected, since I thought the results are promises. The documentation mentioned promises way works just fine. Is this a bug or am I doing something wrong, I'm not sure. Let me know if you tried this, I'd appreciate it.

sub folder error

i have a zip file,
1.Zip
---1.txt
---subFolder
---1.txt
couldn`t extract
is good if without subFolder

how to add the libz library to target

Step 4 in the readme says we should add the libz library to your target, unfortunately I'm not quite sure what that means :)

Sorry to bug you, but I'd really appreciate help!

unzip in background thread

Since this great PR #56 was merged into the master, it's reasonable to make iOS side works in the same way:

  • unzip in the background thread
  • give the real progress event, not just emitted at the beginning and the end.

PRs are welcome.

RNZipArchive. was called with 2 arguments but expects 3 arguments.

Failure when calling ZipArchive.unzip(zipFile, this.bundleDir)

Full error message:

RNZipArchive. was called with 2 arguments but expects 3 arguments. If you haven't changed this method yourself, this usually means that your versions of the native code and JavaScript code are out of sync. Updating both should make this error go away.
Mar  8 17:25:31 [17330]: Possible Unhandled Promise Rejection (id: 0):
	undefined is not an object (evaluating '_unzip(source, target).catch')

When I unwrap to the native call directly, it does indeed have three arguments, the third argument is a callback method which receives a null on completion.

The native call that works looks like this:

var RNZipArchive = NativeModules.RNZipArchive
RNZipArchive.unzip(zipFile, targetDir, (...args)=>console.log("Args ", args));

fragment of my yarn.lock

react-native-zip-archive@^1.1.0:
  version "1.1.0"
  resolved "https://registry.yarnpkg.com/react-native-zip-archive/-/react-native-zip-archive-1.1.0.tgz#7829a6ee18aadf82e52a7a72424ab9b163b97b81"

react-native@^0.42.0:
  version "0.42.0"
  resolved "https://registry.yarnpkg.com/react-native/-/react-native-0.42.0.tgz#59b501603a63232598fff653a36307a26010402e"

zip/unzip variable value

is it currently possible to zip or unzip a variable value ie not a file/asset?

something like:

let text = 'some ascii text that can be zipped';
let bytearray = zip(text);

can not use cocoapods ?

Fetching podspec for RNZipArchive from ../node_modules/react-native-zip-archive
[!] The RNZipArchive pod failed to validate due to 1 error.
[!] The validator for Swift projects uses Swift 3.0 by default, if you are using a different version of swift you can use a .swift-version file to set the version for your Pod. For example to use Swift 2.3, run:
echo "2.3" > .swift-version:
- ERROR | attributes: Missing required attribute homepage.

your RNZipArchive.podspec is error

s.subspec 'RNZASSZipArchive' do |ss|
ss.source_files = 'ios/# RNZASSZipArchive/.{h,m}', 'ios/RNZASSZipArchive/aes/.{h,c}', 'ios/RNZASSZipArchive/minizip/.{h,c}'
ss.private_header_files = 'ios/RNZASSZipArchive/
.h', 'ios/RNZASSZipArchive/aes/.h', 'ios/RNZASSZipArchive/minizip/.h'
end

Manual Installation

Hello,

Can you provide manual installation guid, because in my project rnpm link and react-native link is not working.

After requiring getting error "Cannot read property 'unzip' of undefined"

Using react-native 0.35
Testing on Note 4 - Android 5.1.1

Was following instructions and changed;

  • settings.gradle
  • build.gradle
  • MainApplication.java

Getting no errors in packager, just in console after I require it (didn't even use it anywhere else in code). Can't even start app because I immediately get an error "Cannot read property 'unzip' of undefined". Any help would be highly appreciated.

iOS : Unable to unzip.

Hi,
I am trying to zip a file then unzip the same file. But i am getting error while doing so.
For folder is working perfectly fine but error is thrown in case of a file

Note : for any size of source file , I am always getting zipped file of size 22 bytes.

Any idea what i am doing wrong ?
.
Code :

    const sourcePath = `${MainBundlePath}/main.jsbundle`
    const targetPath = `${MainBundlePath}/demo.zip`

    zip(sourcePath, targetPath)
      .then(path => {
        console.log(`zip completed at ${path}`)

        const targetPath = `${MainBundlePath}/test/`
        const sourcePath = `${MainBundlePath}/demo.zip`

        unzip(sourcePath, targetPath)
          .then(path => {
            console.log(`unzip completed at ${path}`)
          })
          .catch(error => {
            console.log(error) // <--- error catched
          })
      })
      .catch(error => {
        console.log(error)
      })

Error Trace :

Error: unable to unzip
    at createErrorFromErrorData (NativeModules.js:123)
    at NativeModules.js:80
    at MessageQueue.__invokeCallback (MessageQueue.js:307)
    at MessageQueue.js:120
    at MessageQueue.__guard (MessageQueue.js:231)
    at MessageQueue.invokeCallbackAndReturnFlushedQueue (MessageQueue.js:119)
    at debuggerWorker.js:72

"0   ReactNativeDemo                             0x000000010eedb8a6 RCTJSErrorFromCodeMessageAndNSError + 134"
"1   ReactNativeDemo                             0x000000010ee5d038 __41-[RCTModuleMethod processMethodSignature]_block_invoke_2.224 + 184"
"2   ReactNativeDemo                             0x000000010ed14982 -[RNZipArchive unzip:destinationPath:resolver:rejecter:] + 354"
"3   CoreFoundation                      0x0000000110f85c6c __invoking___ + 140"
"4   CoreFoundation                      0x0000000110f85b40 -[NSInvocation invoke] + 320"
"5   CoreFoundation                      0x0000000110f9d956 -[NSInvocation invokeWithTarget:] + 54"
"6   ReactNativeDemo                             0x000000010ee5e463 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 1923"
"7   ReactNativeDemo                             0x000000010ef207f0 _ZN8facebook5react15RCTNativeModule11invokeInnerEjOKN5folly7dynamicE + 784"
"8   ReactNativeDemo                             0x000000010ef203cc _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 60"
"9   ReactNativeDemo                             0x000000010ef20389 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 25"
"10  libdispatch.dylib                   0x00000001138284a6 _dispatch_call_block_and_release + 12"
"11  libdispatch.dylib                   0x000000011385105c _dispatch_client_callout + 8"
"12  libdispatch.dylib                   0x000000011382f94f _dispatch_queue_serial_drain + 221"
"13  libdispatch.dylib                   0x0000000113830669 _dispatch_queue_invoke + 1084"
"14  libdispatch.dylib                   0x0000000113830b32 _dispatch_queue_override_invoke + 654"
"15  libdispatch.dylib                   0x0000000113832ec4 _dispatch_root_queue_drain + 634"
"16  libdispatch.dylib                   0x0000000113832bef _dispatch_worker_thread3 + 123"
"17  libsystem_pthread.dylib             0x0000000113be8712 _pthread_wqthread + 1299"
"18  libsystem_pthread.dylib             0x0000000113be81ed start_wqthread + 13"

Package does not use the progress callback while busy

Hi original author,

Are you aware that in the Android version the progress callback is only called once with 0 and once with 1 in unzipStream()? I have not yet checked the iOS code.

I want to have feedback on the name of the entry being unzipped and the extractedBytes so far...
(so I am trying to fix this in a fork).
The name of this entry would be a good extra parameter to the progress callback.

Also, the variable extractedBytes in the unzipStream() function is not used...

Cheers,
Peter

iOS: Unable to unzip after upgrading React Native to 0.52.0

Hello,

I tried using this package on a new RN project using version 0.52.0 and I couldn't get it to unzip, it gave me the error "unable to unzip".

I tried running the example given in this repository, and everything worked fine. I then upgraded the version of RN used from 0.48.4 to 0.52.0 (and React from 16.0.0-alpha.12 to 16.2.0) and the error came back.

Error: unable to unzip
    at createErrorFromErrorData (1502c86f-3c8c-4ead-a…0-11a52f74cecf:7068)
    at 1502c86f-3c8c-4ead-a…0-11a52f74cecf:7020
    at MessageQueue.__invokeCallback (1502c86f-3c8c-4ead-a…0-11a52f74cecf:7462)
    at 1502c86f-3c8c-4ead-a…0-11a52f74cecf:7207
    at MessageQueue.__guardSafe (1502c86f-3c8c-4ead-a…0-11a52f74cecf:7375)
    at MessageQueue.invokeCallbackAndReturnFlushedQueue (1502c86f-3c8c-4ead-a…0-11a52f74cecf:7206)
    at debuggerWorker.js:72

NPM release for 0.40 support

Many of us don't feel comfortable pinning a dependency to latest. Would it be possible for you to do an npm patch release?

New NPM release for RN >= 0.40

Could you please create a new release for React Native 0.40? Current version (0.0.11) doesn't work with RN 0.40, but the master branch seems to already contain all the necessary changes.

Unzip on IOS

Hello,

I succeed to use this module on Android, but when I switch to IOS it doesn't work anymore without error message but a tiny "unzip error". Is there a working example for IOS ? (I'm just using ZipArchive.unzip method).

Thanks !

Suport for RAR formats

Have you considered extending react-native-zip-archive to rar files? I've been trying to use Unrar4iOS and UnrarKit via native function exports but couldn't make it work.

Btw, great work on the library so far :)

Error compiling package

:react-native-zip-archive:processReleaseResources

 UP-TO-DATE
:react-native-zip-archive:generateReleaseSources UP-TO-DATE
:react-native-zip-archive:incrementalReleaseJavaCompilationSafeguard UP-TO-DATE
:react-native-zip-archive:compileReleaseJavaWithJavac
:react-native-zip-archive:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
/Users/username/Documents/appname/node_modules/react-native-zip-archive/android/src/main/java/com/rnziparchive/RNZipArchivePackage.java:20: error: method does not override or implement a method from a supertype
  @Override
  ^
1 error
:react-native-zip-archive:compileReleaseJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-zip-archive:compileReleaseJavaWithJavac'.

React Native v0.52.0
React Native CLI v2.0.1
Building for Android

What do you suggest for this error?

Unzipping failes on Android - Does not recognize zip file

I am trying to unzip this testfile (https://www.dropbox.com/s/d2fbgpf3mivw23c/peace.zip?dl=0) which I got from here http://www.colorado.edu/conflict/peace/download/index.html (peace.zip).
I downloaded the data with react-native-fetch-blob

RNFetchBlob
      .config({
        fileCache: true,
        appendExt: "zip"
      })
      .fetch("GET", "https://www.dropbox.com/s/d2fbgpf3mivw23c/peace.zip?dl=0", {
      })
    })

I then hardcode the link to the zip-file, for testing purposes:

unzip("/data/data/com.MAYAPP/files/RNFetchBlobTmp_e2hsvk6g0082wntmvduai.zip", "/data/data/com.MYAPP/files/someFolder")
          .then((path) => {
            console.log(`unzip completed at ${path}`)
          })
          .catch((error) => {
            console.log(error)
          })

That gives me:

YellowBox.js:76 Error: Failed to extract file error in opening zip file
at createErrorFromErrorData (NativeModules.js:117)
at NativeModules.js:80
at MessageQueue.__invokeCallback (MessageQueue.js:354)
at MessageQueue.js:129
at MessageQueue.__guard (MessageQueue.js:269)
at MessageQueue.invokeCallbackAndReturnFlushedQueue (MessageQueue.js:128)
at debuggerWorker.js:72

It is a zip file though. I can access the file and unzipp it on my computer, but not through the library. Any ideas?

react-native-cli: 2.0.1
react-native: 0.48.3
npm: 5.3.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.