You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One of the files in my zip is a JSON file. I would like to stream in the zip and when I get to this file pull the contents directly into a string rather than write to a file then read from that file.
Is that sort of thing possible?
The text was updated successfully, but these errors were encountered:
This code snippet will extract JSON data from a file inside a streamed zip archive without writing any temp files. It's asynchronous and JSON.parse can directly access the buffer, so no string conversion is necessary. Zipped files which aren't 'package.json' are ignored.
varrequest=require('request');varthrough=require('through2');varunzip=require('unzip');request('https://github.com/EvanOxfeld/node-unzip/archive/master.zip').pipe(unzip.Parse()).on('entry',function(entry){if(entry.path.indexOf('package.json')>-1){entry.pipe(through.obj(function(contents){// contents is a buffer containing the JSON datavarjsonData=JSON.parse(contents);console.log(jsonData);}))}else{entry.autodrain();}});
One of the files in my zip is a JSON file. I would like to stream in the zip and when I get to this file pull the contents directly into a string rather than write to a file then read from that file.
Is that sort of thing possible?
The text was updated successfully, but these errors were encountered: