adm-zip: Zip file is empty - sort of...
Hi,
I’ve been wrestling with this issue for the last 2 hours and am convinced that I must be doing something woefully dumb.
I am trying to create a zip archive that contains exactly 1 file - a text (log) file. Shown below is my latest attempt, but I also tried the addLocalFile method described in the documentation.
In all cases the result is the same:
- The zip file is created
- When I point a web browser to it to cause standard browser download behavior, the zip file appears to be properly downloaded.
- But when I open the archive in Windows Explorer (Windows 2012 Server) either using standard Windows filesystem logic, or using 7-Zip, the zip is empty. Specifically,
- In Explorer the zip file shows a length of 67K
- When I double-click on it, it opens to the next level, showing the filename that I assigned, but it shows a type of “File Folder”
- When I double-click again, it says “This folder is empty”
I should also point out that within the Linux (CentOS 6) shell, I can run the unzip command against the archive and it all works as expected.
So either I’m doing something wrong, or is there some dependency on Windows?
Thanks very much for your help.
-Paul
fs.readFile(fqLogPath, function (err, buffer) {
if (err)
{
console.log('FAILURE')
return;
}
var zip = new AdmZip();
zip.addFile(uniqueId + '.txt', buffer);
zip.writeZip(__dirname + '/public/' + uniqueId + '.zip');
});
About this issue
- Original URL
- State: open
- Created 8 years ago
- Reactions: 9
- Comments: 17
@niczak Yeah, that’s one of the way you can achieve it, but better one is, add following code in adm-zip.js code.
if (!attr) {
Hi guys i’m actually running into this issue to. Fighting with adm-zip for hours without much result. This problem seems to only occurs in a Windows environment.
For what it’s worth, here are the steps to reproduce it :
Running into this issue as well. I personally use WinRar and it’s able to see the files, but other windows users are not. I was hoping this was a format issue that could be changed in the constructor. But since there’s no replies perhaps this is an unresolved issue.
If that’s the case then this is a deal breaker and I’ll need to find another library.
Here is how I got around this issue:
^— Works on Linux, OSX, Windows.
@niczak buffer (binary)