react-native-zip-archive
react-native-zip-archive copied to clipboard
FileNotFound Exception while unzipping the file in Android
Describe the bug Whenever i try to unzip file to a specific destination using unZip function, It throws the warning fileNotfound. when i checked for the zip file in the respective path, it's present in the file system.
React-Native : 0.63.3 react-native-zip-archive: 7.0.0
Can you attach the file you're using? It's hard to tell what's going wrong without the file and the code.
Same here.
Error: Failed to extract file java.io.FileNotFoundException: /data/user/0/com.lesbaladesdedecouverto/files/decouverto/PNDXGzA/images/74PMrHw.jpg: open failed: EACCES (Permission denied)]
Any updates on this? Currently getting the same error (ENOENT).
java.io.FileNotFoundException: /storage/emulated/0/Download/canada.zip: open failed: ENOENT (No such file or directory): Error: java.io.FileNotFoundException: /storage/emulated/0/Download/canada.zip: open failed: ENOENT (No such file or directory)
It's only happening on some phones for me (e.g., Samsung Galaxy S24 Ultra). With other Android and iOS apps the zip completes successfully. Here is an example of the code I'm running with logs:
export const zipFile = async (sourcePath: string, targetPath: string) => {
try {
const fileExists = await RNFS.exists(sourcePath);
LoggerService.info(`fileExists: ${fileExists}`);
const targetFileExists = await RNFS.exists(targetPath);
LoggerService.info(`targetFileExists: ${targetFileExists}`);
LoggerService.info(`readdir: ${await RNFS.readdir(sourcePath)}`);
return await zip(sourcePath, targetPath);
} catch (error: any) {
LoggerService.error(`Unable to create zip at ${targetPath} src=${sourcePath}`, error);
throw error;
}
};
2025-03-11T16:29:25.239Z [INFO] fileExists: true
2025-03-11T16:29:25.240Z [INFO] targetFileExists: false
2025-03-11T16:29:25.244Z [INFO] readdir: Canada_PROPERTY_DETAILS.pdf
2025-03-11T16:29:25.257Z [ERROR] Unable to create zip at /storage/emulated/0/Download/canada.zip src=/storage/emulated/0/Documents/ValueConnect/canada java.io.FileNotFoundException: canada.zip: open failed: ENOENT (No such file or directory): Error: java.io.FileNotFoundException: /storage/emulated/0/Download/canada.zip: open failed: ENOENT (No such file or directory)
at promiseMethodWrapper (address at index.android.bundle:1:73311)
at zip (address at index.android.bundle:1:1951499)
at ?anon_0_ (address at index.android.bundle:1:1950277)
at next (native)
at asyncGeneratorStep (address at index.android.bundle:1:534092)
at _next (address at index.android.bundle:1:534349)
at tryCallOne (/root/react-native/packages/react-native/ReactAndroid/hermes-engine/.cxx/MinSizeRel/3v1xb2f2/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:53:16)
at anonymous (/root/react-native/packages/react-native/ReactAndroid/hermes-engine/.cxx/MinSizeRel/3v1xb2f2/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:139:27)
at apply (native)
at anonymous (address at index.android.bundle:1:190672)
at _callTimer (address at index.android.bundle:1:189623)
at _callReactNativeMicrotasksPass (address at index.android.bundle:1:189767)
at callReactNativeMicrotasks (address at index.android.bundle:1:191762)
at __callReactNativeMicrotasks (address at index.android.bundle:1:77487)
at anonymous (address at index.android.bundle:1:76570)
at __guard (address at index.android.bundle:1:77325)
at flushedQueue (address at index.android.bundle:1:76481)
at invokeCallbackAndReturnFlushedQueue (address at index.android.bundle:1:76424)
I solved my problem by looking at the content of the zip: on the new android it seems when you have a subfolder with images/ inside for example, this will probably fail because you don't have the permissions to access to the image of the user.
Mit freundlichen Grüßen / Bien cordialement / Best regards, Cédric JUNG
Le mar. 11 mars 2025 à 17:14, Ryan Sheppard @.***> a écrit :
Any updates on this? Currently getting the same error (ENOENT).
java.io.FileNotFoundException: /storage/emulated/0/Download/canada.zip: open failed: ENOENT (No such file or directory): Error: java.io.FileNotFoundException: /storage/emulated/0/Download/canada.zip: open failed: ENOENT (No such file or directory)
It's only happening on some phones for me (e.g., Samsung Galaxy S24 Ultra). With other Android and iOS apps the zip completes successfully.
— Reply to this email directly, view it on GitHub https://github.com/mockingbot/react-native-zip-archive/issues/311#issuecomment-2714934254, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIOFSY6S6RAGYMDMQBYWUL2T4DWLAVCNFSM6AAAAABYZK5BG2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMJUHEZTIMRVGQ . You are receiving this because you commented.Message ID: @.***> [image: ryanshepps]ryanshepps left a comment (mockingbot/react-native-zip-archive#311) https://github.com/mockingbot/react-native-zip-archive/issues/311#issuecomment-2714934254
Any updates on this? Currently getting the same error (ENOENT).
java.io.FileNotFoundException: /storage/emulated/0/Download/canada.zip: open failed: ENOENT (No such file or directory): Error: java.io.FileNotFoundException: /storage/emulated/0/Download/canada.zip: open failed: ENOENT (No such file or directory)
It's only happening on some phones for me (e.g., Samsung Galaxy S24 Ultra). With other Android and iOS apps the zip completes successfully.
— Reply to this email directly, view it on GitHub https://github.com/mockingbot/react-native-zip-archive/issues/311#issuecomment-2714934254, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIOFSY6S6RAGYMDMQBYWUL2T4DWLAVCNFSM6AAAAABYZK5BG2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMJUHEZTIMRVGQ . You are receiving this because you commented.Message ID: @.***>
It appears the issue is with net.lingala.zip4j.zip4j. I compiled react-native-zip-archive locally with my own logs and was able to get the following stack trace:
net.lingala.zip4j.exception.ZipException: java.io.FileNotFoundException: /storage/emulated/0/Download/canada.zip: open failed: ENOENT (No such file or directory)
at net.lingala.zip4j.tasks.AsyncZipTask.performTaskWithErrorHandling(AsyncZipTask.java:58)
at net.lingala.zip4j.tasks.AsyncZipTask.execute(AsyncZipTask.java:45)
at net.lingala.zip4j.ZipFile.addFiles(ZipFile.java:319)
at net.lingala.zip4j.ZipFile.addFile(ZipFile.java:276)
at com.rnziparchive.RNZipArchiveModule$4.run(RNZipArchiveModule.java:411)
at java.lang.Thread.run(Thread.java:1012)
Caused by: java.io.FileNotFoundException: /storage/emulated/0/Download/canada.zip: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:574)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:289)
at net.lingala.zip4j.io.outputstream.SplitOutputStream.<init>(SplitOutputStream.java:51)
at net.lingala.zip4j.tasks.AbstractAddFileToZipTask.addFilesToZip(AbstractAddFileToZipTask.java:66)
at net.lingala.zip4j.tasks.AddFilesToZipTask.executeTask(AddFilesToZipTask.java:33)
at net.lingala.zip4j.tasks.AddFilesToZipTask.executeTask(AddFilesToZipTask.java:20)
at net.lingala.zip4j.tasks.AsyncZipTask.performTaskWithErrorHandling(AsyncZipTask.java:51)
... 5 more
Unfortunately I do not understand zip4j enough to continue.
@ryanshepps great insights—thanks for putting in the effort on this!
I was wondering if there are any alternatives to zip4j we could explore, since it’s no longer being actively maintained.