Node.js - get Filename of received .zip

Viewed 1386

A user POSTs a .zip file to my REST-Server.

I receive them by using:

app.use(bodyParser.raw({            //to support .zips
  type: 'application/octet-stream',
  limit: '1500mb'
}));

I do not want to let the user send the filename seperately as it should be contained within the bytes/buffer which I am receiving right?

With the following code I only get the names of the .zip content:

var unzip = require('unzip');
var stream = require('stream');
var bufferStream = new stream.PassThrough();        
bufferStream.end(fileBuffer);        

bufferStream
.pipe(unzip.Parse())
.on('entry', function (entry) {
  var fileName = entry.path;
  var type = entry.type; // 'Directory' or 'File' 
  var size = entry.size;
  (...)

How do I extract the fileName of the .zip out of the buffer?

0 Answers
Related