Thursday 4 May 2017

I want to unzip the zip file and upload it to S3

This is my code. It unzips the zip file and writes it to local.

    var unzip = require('unzip')
    fs.createReadStream('zip/test.zip')
          .pipe(unzip.Parse())
          .on('entry', function (entry) {
            var fileName = entry.path
            var type = entry.type
            if (type === 'File') {
              entry.pipe(fs.createWriteStream('unzip/'));
            } else {
              entry.autodrain();
            }
          });

I do not want to write it locally, but I want to upload it to AWS S3.

That is, I want to change the part of entry.pipe(fs.createWriteStream('unzip/')) to the process of uploading to S3.

I am using this library. https://github.com/EvanOxfeld/node-unzip

Are there any good ideas?



via tomoya ishizaka

No comments:

Post a Comment