Created
August 3, 2013 02:24
-
-
Save andrecaribe/6144848 to your computer and use it in GitHub Desktop.
"bad zipfile offset (local header sig)"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fs.writeFile(jsonFile, json, function (err) { | |
if (err) { | |
res.send(500, JSON.parse('{"code": 500, "description":"' + err + '"}')); | |
return; | |
} | |
var fileName = pathToFiles + "exercises/B" + req.params.bookId + "L" + req.params.lessonId + ".zip"; | |
var output = fs.createWriteStream(fileName); | |
var archive = archiver('zip'); | |
archive.on('error', function(err) { | |
res.send(500, JSON.parse('{"code": 500, "description":"' + err + '"}')); | |
return; | |
}); | |
archive.pipe(output); | |
for (var k = 0; k < dataToZip.length; k++) { | |
console.log("path %s name %s", dataToZip[k].path, dataToZip[k].name); | |
archive.append(fs.createReadStream(dataToZip[k].path), { name: dataToZip[k].name }); | |
} | |
archive.finalize(function(err, written) { | |
if (err) { | |
res.send(500, JSON.parse('{"code": 500, "description":"' + err + '"}')); | |
return; | |
} | |
res.send(200, JSON.parse('{"code": 200, "file":"http://hermes.ezlearn.com.br/files/exercises/B' + req.params.bookId + "L" + req.params.lessonId + '.zip"}')); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment