mockingbot / react-native-zip-archive

Zip archive utility for react-native
MIT License
425 stars 156 forks source link

iOS : Unable to unzip. #60

Closed ayushnawani closed 6 years ago

ayushnawani commented 7 years ago

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"
scerelli commented 7 years ago

same here, dunno why! the curious thing is that yesterday it was working great, but even if i did nothing special on the zip process, today it doesn't work anymore.

this is the error: https://cl.ly/1j0q0S3r3o1k i tried with version 1.1.1/2.0 and the latest release. i am on ios 11.

here is my code:

const unzippedPathName = response.data.substring(response.data.lastIndexOf('/') + 1).replace('.zip', '');
        const unzippedPath = `${folder}/${unzippedPathName}`;
        unzip(response.data, unzippedPath)
          // TODO: Delete unzipped zip
          .then(() => {
            Actions.onDownloadComplete({
              id: modelId,
              path: unzippedPath
            });
            itemsSlice();
          })
          .catch((error) => {
            Actions.onDownloadError({id: modelId, error});
            itemsSlice();
          });
plrthink commented 7 years ago

ok, will check this tonight

EyalSi commented 7 years ago

Got the same error on iOS. unable to unzip any file...(works on android) iOS:11 "react-native": "^0.48.4", "react-native-zip-archive": "2.1.0",

This is really amazing. Without this package, it is practically impossible to unzip a file in react native...

This is the error I get:

2017-10-09 00:39:24.369 [info][tid:com.facebook.react.JavaScript] {"line":1766 "column":24 "sourceURL":"http://192.168.1.31.xip.io:8081/index.bundle?platform=ios&dev=true&minify=false&hot=true" "framesToPop":1 "code":"unzip_error" "nativeStackIOS":["0 Anashim 0x0000000102cc7000 RCTJSErrorFromCodeMessageAndNSError + 152" "1 Anashim 0x0000000102c5295c __41-[RCTModuleMethod processMethodSignature]_block_invoke_2.216 + 192" "2 Anashim 0x00000001033af08c -[RNZipArchive unzip:destinationPath:resolver:rejecter:] + 360" "3 CoreFoundation 0x000000018288b6a0 + 144" "4 CoreFoundation 0x000000018276a820 + 292" "5 CoreFoundation 0x000000018276f22c + 60" "6 Anashim 0x0000000102c53dd0 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 1704" "7 Anashim 0x0000000102d09bc0 _ZN8facebook5react15RCTNativeModule11invokeInnerEjOKN5folly7dynamicE + 612" "8 Anashim 0x0000000102d0980c _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 84" "9 Anashim 0x0000000102d097ac ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 28" "10 libdispatch.dylib 0x00000001042f949c _dispatch_call_block_and_release + 24" "11 libdispatch.dylib 0x00000001042f945c _dispatch_client_callout + 16" "12 libdispatch.dylib 0x0000000104308110 _dispatch_queue_serial_drain + 692" "13 libdispatch.dylib 0x00000001042fc9a4 _dispatch_queue_invoke + 332" "14 libdispatch.dylib 0x0000000104309104 _dispatch_root_queue_drain_deferred_wlh + 424" "15 libdispatch.dylib 0x0000000104310100 _dispatch_workloop_worker_thread + 652" "16 libsystem_pthread.dylib 0x00000001824aefe0 _pthread_wqthread + 932" "17 libsystem_pthread.dylib 0x00000001824aec30 start_wqthread + 4"] "userInfo":null "domain":"RCTErrorDomain"}

EyalSi commented 7 years ago

I found the problem in my case. I'm using react-native-document-picker. the file name received on iOS starts with file://. Removing it, fixed the problem...

ducpt2 commented 6 years ago

[iOS] Still the same problem. @EyalSi my ios file start with: ""/private/var/mobile..." Any helps?

qq912276337 commented 6 years ago

i zip succeed in ios11 !but i open this zip file failured in macOS.how to solve it?

ecexplorer commented 6 years ago

Having an issue zipping in iOS. Verified file paths & iOS setup. Similar to what people report here, I end up w/ a 22 byte zip file that can't be opened. Original file (uncompressed) is formatted & of expected size.

plrthink commented 6 years ago

just published the 2.2.6 which should fix this problem. sorry for such a late fix.

ecexplorer commented 6 years ago

@plrthink Thanks for the fix! Can confirm that I'm now able to zip a single file.

MRDANX commented 4 years ago

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

It just happens in iOS, Android works fine. This problem happen again at exact version 5.0.2, when I fall back to version 5.0.1 solved it.

plrthink commented 4 years ago

@MRDANX Can you show the code you're using? I can test it with the example and it works as expected.

MRDANX commented 4 years ago

@plrthink It's because I was zipping the plain text file, but v5.0.2 no longer supports zipping plain files, so I finally got the answer. the related issue here #204

plrthink commented 4 years ago

@MRDANX Ok, that's indeed a problem which I would fix in the next release.