-1

can someone suggest npm package for extract 7z file for node.js.

I can see some npm package available for ZIP file but that does not work for the 7Z file.

I'm basically looking to extract 7z password protect file on S3 and read the data from 7z file.

  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Feb 22 '22 at 02:13

1 Answers1

0

Give node-7z package a try:

npm i node-7z
import Seven from 'node-7z'

// myStream is a Readable stream
const myStream = Seven.extractFull('./archive.7z', './output/dir/', {
  $progress: true
})

myStream.on('data', function (data) {
  doStuffWith(data) //? { status: 'extracted', file: 'extracted/file.txt" }
})

myStream.on('progress', function (progress) {
  doStuffWith(progress) //? { percent: 67, fileCount: 5, file: undefinded }
})

myStream.on('end', function () {
    // end of the operation, get the number of folders involved in the operation
  myStream.info.get('Folders') //? '4'
})

myStream.on('error', (err) => handleError(err))

It also supports password feature you were requesting mate.

Allan Chua
  • 9,305
  • 9
  • 41
  • 61
  • Concern with this package deal with local folder but I'm looking to extract 7zfiles on the AWS S3 bucket. – Alpesh Dhori Feb 10 '22 at 10:35
  • 1
    @AlpeshDhori, S3 is not a block file system. its an object storage. – Allan Chua Feb 10 '22 at 13:54
  • Allan Chua, The code you provided accept the local folder path and what I'm looking is this code on AWS Lambda to extract on the S3 bucket. – Alpesh Dhori Feb 11 '22 at 06:34
  • For anyone coming here in the future, you can use the /tmp space in a Lambda. The ephemeral file system size can be up to 10GB. – Anders Apr 29 '23 at 12:31
  • And with AWS SDK v3 for S3 you should (theoretically, at least) be able to use a read- and write stream, directly from/to S3. – Anders Apr 29 '23 at 12:33