All Projects → archiverjs → Node Archiver

archiverjs / Node Archiver

Licence: mit
a streaming interface for archive generation

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to Node Archiver

Afs
Abstract File Storage
Stars: ✭ 126 (-94.52%)
Mutual labels:  zip, tar
Ugrep
🔍NEW ugrep v3.1: ultra fast grep with interactive query UI and fuzzy search: search file systems, source code, text, binary files, archives (cpio/tar/pax/zip), compressed files (gz/Z/bz2/lzma/xz/lz4), documents and more. A faster, user-friendly and compatible grep replacement.
Stars: ✭ 626 (-72.78%)
Mutual labels:  zip, tar
uncompress.js
Uncompress ZIP, RAR, and TAR files with pure JavaScript
Stars: ✭ 79 (-96.57%)
Mutual labels:  zip, tar
comi
ComiGO:Simple, cross-platform manga reader。简单、跨平台的漫画阅读器。シンプルな漫画リーダー。
Stars: ✭ 34 (-98.52%)
Mutual labels:  zip, tar
Sharpcompress
SharpCompress is a fully managed C# library to deal with many compression types and formats.
Stars: ✭ 1,397 (-39.26%)
Mutual labels:  zip, tar
zipstream
A command line tool that allows you to easily share files and directories over the network
Stars: ✭ 49 (-97.87%)
Mutual labels:  zip, tar
Decompress
Extracting archives made easy
Stars: ✭ 316 (-86.26%)
Mutual labels:  zip, tar
extractor
Compressed files extractor for PHP
Stars: ✭ 23 (-99%)
Mutual labels:  zip, tar
Libarchivejs
Archive library for browsers
Stars: ✭ 145 (-93.7%)
Mutual labels:  zip, tar
Pyfilesystem2
Python's Filesystem abstraction layer
Stars: ✭ 1,256 (-45.39%)
Mutual labels:  zip, tar
unarr
A decompression library for rar, tar, zip and 7z archives
Stars: ✭ 35 (-98.48%)
Mutual labels:  zip, tar
Libarchive
Multi-format archive and compression library
Stars: ✭ 1,625 (-29.35%)
Mutual labels:  zip, tar
QArchive
Async C++ Cross-Platform library that modernizes libarchive using Qt5 🚀. Simply extracts 7z 🍔, Tarballs 🎱 and other supported formats by libarchive. ❤️
Stars: ✭ 66 (-97.13%)
Mutual labels:  zip, tar
ratarmount
Random Access Read-Only Tar Mount
Stars: ✭ 217 (-90.57%)
Mutual labels:  zip, tar
compress
compress and uncompress for Deno
Stars: ✭ 29 (-98.74%)
Mutual labels:  zip, tar
Archiver
Easily create & extract archives, and compress & decompress files of various formats
Stars: ✭ 3,373 (+46.65%)
Mutual labels:  zip, tar
MangDL
The most inefficient Manga downloader for PC
Stars: ✭ 40 (-98.26%)
Mutual labels:  zip, tar
archiver-zip-encrypted
Plugin for archiver to create ZIP archives with password using either AES or legacy Zip 2.0 encryption
Stars: ✭ 50 (-97.83%)
Mutual labels:  zip, archiver
Leanify
lightweight lossless file minifier/optimizer
Stars: ✭ 694 (-69.83%)
Mutual labels:  zip, tar
Swcompression
A Swift framework for working with compression, archives and containers.
Stars: ✭ 110 (-95.22%)
Mutual labels:  zip, tar

Archiver

A streaming interface for archive generation

Visit the API documentation for a list of all methods available.

Install

npm install archiver --save

Quick Start

// require modules
const fs = require('fs');
const archiver = require('archiver');

// create a file to stream archive data to.
const output = fs.createWriteStream(__dirname + '/example.zip');
const archive = archiver('zip', {
  zlib: { level: 9 } // Sets the compression level.
});

// listen for all archive data to be written
// 'close' event is fired only when a file descriptor is involved
output.on('close', function() {
  console.log(archive.pointer() + ' total bytes');
  console.log('archiver has been finalized and the output file descriptor has closed.');
});

// This event is fired when the data source is drained no matter what was the data source.
// It is not part of this library but rather from the NodeJS Stream API.
// @see: https://nodejs.org/api/stream.html#stream_event_end
output.on('end', function() {
  console.log('Data has been drained');
});

// good practice to catch warnings (ie stat failures and other non-blocking errors)
archive.on('warning', function(err) {
  if (err.code === 'ENOENT') {
    // log warning
  } else {
    // throw error
    throw err;
  }
});

// good practice to catch this error explicitly
archive.on('error', function(err) {
  throw err;
});

// pipe archive data to the file
archive.pipe(output);

// append a file from stream
const file1 = __dirname + '/file1.txt';
archive.append(fs.createReadStream(file1), { name: 'file1.txt' });

// append a file from string
archive.append('string cheese!', { name: 'file2.txt' });

// append a file from buffer
const buffer3 = Buffer.from('buff it!');
archive.append(buffer3, { name: 'file3.txt' });

// append a file
archive.file('file1.txt', { name: 'file4.txt' });

// append files from a sub-directory and naming it `new-subdir` within the archive
archive.directory('subdir/', 'new-subdir');

// append files from a sub-directory, putting its contents at the root of archive
archive.directory('subdir/', false);

// append files from a glob pattern
archive.glob('file*.txt', {cwd:__dirname});

// finalize the archive (ie we are done appending files but streams have to finish yet)
// 'close', 'end' or 'finish' may be fired right after calling this method so register to them beforehand
archive.finalize();

Formats

Archiver ships with out of the box support for TAR and ZIP archives.

You can register additional formats with registerFormat.

You can check if format already exists before to register a new one with isRegisteredFormat.

Formats will be changing in the future to implement a middleware approach.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].