Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unzipAssets does not work on android platform. #173

Closed
xclidongbo opened this issue Sep 24, 2019 · 6 comments · May be fixed by #306
Closed

unzipAssets does not work on android platform. #173

xclidongbo opened this issue Sep 24, 2019 · 6 comments · May be fixed by #306
Assignees
Labels

Comments

@xclidongbo
Copy link

xclidongbo commented Sep 24, 2019

react-native-cli: 2.0.1
react-native: 0.59.10
"react-native-zip-archive": "4.1.5"

import RNFS from 'react-native-fs';
import {zip, unzip, unzipAssets, subscribe} from 'react-native-zip-archive';
......

let rootZipPath = 'app.zip';
let  documentPath = RNFS.ExternalCachesDirectoryPath+'/Documents';
if (true == await RNFS.existsAssets(rootZipPath)){
          try {
            await unzipAssets(rootZipPath, documentPath)
          } catch (error) {
            console.log(error);
          } 
        }

Error:

Error: Asset file `app.zip` could not be opened
    at createErrorFromErrorData (NativeModules.js:155)
    at NativeModules.js:104
    at MessageQueue.__invokeCallback (MessageQueue.js:414)
    at MessageQueue.js:127
    at MessageQueue.__guard (MessageQueue.js:314)
    at MessageQueue.invokeCallbackAndReturnFlushedQueue (MessageQueue.js:126)
    at debuggerWorker.js:80
@bimbox-open
Copy link

@xclidongbo Hi there! I found this error, too. I solved by this way: use method 'copyFileAssets' on https://github.com/itinance/react-native-fs/.
execute these below: (RNFS === react-native-fs)
Step1: RNFS.copyFileAssets(${androidAssetsUri}, ${targetPath}/tmp)
Step2: unzip(${targetPath}/tmp, documentPath),
Step3: RNFS.unlink(${targetPath}/tmp)

@xclidongbo
Copy link
Author

@bimbox-open Good job!

@plrthink
Copy link
Collaborator

This maybe caused by the permissions. I would take a look ASAP.

@plrthink plrthink self-assigned this Sep 25, 2019
@smontlouis
Copy link

@plrthink Any news regarding this ? I'm getting the same issues.

@plrthink
Copy link
Collaborator

@bulby97 sorry, no. But could you please try the tmp solution suggested by @xclidongbo ? And we would fix this maybe in the next release.

@irfana1716
Copy link

@bimbox-open Can you please confirm the androidAssetsUri in copyassetsfile. I am still getting a same error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants