javascript - How to extract a ZIP file from a HTTP resource with node.js -
how extract zip file http resource node.js?
i tried the below code got error indicating zip file may corrupt (which isn't):
require('node-zip'); var request = require('request'); request('http://data.geo.admin.ch.s3.amazonaws.com/ch.meteoschweiz.swissmetnet/data.zip', function (error, response, body) { if (!error && response.statuscode == 200) { console.log(new jszip(body, {base64: false, checkcrc32: true}).files); } })
error:
error: end of info reached (data length = 230973, asked index = 261475). corrupted zip ?
request
tries decode content text, corrupting data. seek :
request({ method : "get", url : "http://data.geo.admin.ch.s3.amazonaws.com/...", encoding: null // <- 1 of import ! }, function (error, response, body) { if (!error && response.statuscode == 200) { console.log(new jszip(body).files); // handle error return; } });
see http://stuk.github.io/jszip/documentation/howto/read_zip.html (the request
illustration @ bottom of page).
javascript node.js
No comments:
Post a Comment