react-native-zip-archive
react-native-zip-archive copied to clipboard
can't unzip no one file
first of all i tried download file via rn-fetch-blob, and unzip got path - Couldn't open file then i locally place file in correct directory and same issue - Couldn't open file tried different zip files and every time same issue
via rn-fetch-blob
RNFetchBlob.config({
fileCache: true,
path: DocumentDirectoryPath + '/my.zip',
})
.fetch('GET', 'https://file-examples-com.github.io/uploads/2017/02/zip_5MB.zip')
.then(res => {
const targetPath = DocumentDirectoryPath
unzip(res.path(), targetPath)
.then(path => {
console.log(`unzip completed at ${path}`)
})
.catch(error => {
console.error(error)
})
})
place file locally into directory and got - Failed to extract file error in opening zip file
const filePath = `${DocumentDirectoryPath}/my.zip`;
const targetPath = DocumentDirectoryPath;
unzip(filePath, targetPath)
.then(path => {
console.log(`unzip completed at ${path}`)
})
.catch(error => {
console.error(error)
})
})
+1
any update on this seems like package is broken ? @plrthink
@chiefchief Can you place the file you're working with? It's hard to tell what's wrong with your code since it's working on my side.
@chiefchief there could be few reasons i.e 1 - path is incorrect 2 - zip file is broken
in my case my path was wrong i created a utility for myself, see if you can use it:
export const unzipMethod = (slug) => {
RNFS.mkdir(`${RNFS.DocumentDirectoryPath}/${slug}`).then(() => {
const sourcePath = `${RNFS.DocumentDirectoryPath}/${slug}.zip`;
const targetPath = `${RNFS.DocumentDirectoryPath}/${slug}/`;
unzip(sourcePath, targetPath)
.then(() => {
console.log('unzipped');
RNFS.unlink(`${RNFS.DocumentDirectoryPath}/${slug}.zip`);
})
.catch((error) => {
console.log(error);
});
});
};
slug in my case is the name of zip file and the folder name i want to create, just remember to add "/" at the last in target path it will make sure to unzip under the folder
I'm not sure if this is the same problem, but I can't unzip anything either. Autolinking isn't working — I get TypeError: null is not an object (evaluating 'RNZipArchive.unzip'). Any ideas? I'm using Expo but didn't have much luck with straight React Native either.
@elon-gs I'm happy to help you if you can provide a minimal reproducible repo.
my file is save but i unable to where is the file will save?????