2

When I use archiverjs I cannot open the resulting zip file:

var archive = archiver('zip');
  var output = fs.createWriteStream(projectName + '.zip');
archive.pipe(output);

  archive.on('error', function(err) {
    throw err;
  });
  output.on('close', function() { 
    console.log('Package complete!');
  });
  archive.bulk([
    {expand: true, cwd: projectPath, src:['**/*'], data: {mode: 0755}}
  ]).finalize();

The zip file gets created but I dont have permissions to open it. What am I doing wrong?

dopatraman
  • 13,416
  • 29
  • 90
  • 154
  • Just a check: is the issue that you cannot open the zip file itself, or that you don't have the right permissions on the files coming from the zip once you've extracted them? – Simon Groenewolt May 17 '16 at 20:23
  • I cannot open the zipfile itself, meaning i cannot extract. I'm assume the files themselves are accessible, since I can open then pre zip. – dopatraman May 18 '16 at 00:13
  • Are you sure the file is being written to `projectPath/`. I would expect the write stream to get something like `path.join(projectPath, projectName + '.zip')` – Ryan Wheale May 18 '16 at 18:34
  • 1
    Yes, the zip file is being written. I just cannot extract the files. – dopatraman May 18 '16 at 18:50
  • DOH, just noticed this. Being that you are using streams, you need to make sure the bulk command happens _after_ the output stream and anything else piped onto the archive stream is done. – Ryan Wheale May 18 '16 at 19:01
  • I ran your code successfully without change in my machine, maybe its not the posted code that does this, it might be something is interrupting zipping operation, other code maybe – Abdullah Shahin May 18 '16 at 20:29

0 Answers0