memory-tar-create

Create gzipped tar archives in memory and download them as files or base64 strings.

Usage no npm install needed!

<script type="module">
  import memoryTarCreate from 'https://cdn.skypack.dev/memory-tar-create';
</script>

README

memory-tar-create

Create gzipped tar archives in memory and download them as files or base64 strings.

NPM Package GitHub Sponsors Patreon Slack


Creating a Tar file in memory

import Tar from 'memory-tar-create';

// Create your initial tar archive with a file
const myTar = new Tar({
    'test.txt': { contents: 'Hello world' },
});

// Add some more files to the archive
myTar.add({
    'a.txt': { contents: 'apple' },
    'b.txt': { contents: 'banana' },
});

// Add a symlink to the archive
myTar.add({
    'hello.txt': { target: 'test.txt' },
});

// Remove a file from the archive
myTar.remove('a.txt');

// Add a file modified at the start of 2020
myTar.add({
    'old.txt': { contents: 'Old?', modified: new Date(2020, 1, 1, 0, 0, 0, 0) },
});

// gzip the archive
const gzipTar = myTar.gz();

// Get the base64 of the gzipped archive
const b64GzippedTar = gzipTar.base64();

// Or, get the base64 string as a shell command for the archive
const b64CommandGzippedTar = gzipTar.base64('myTar.tar.gz');

// Or, in a browser, download the archive directly
gzipTar.download('myTar.tar.gz');

Logic originally created for digitalocean/nginxconfig.io.

Contributing

Contributions are always welcome to this project!
Take a look at any existing issues on this repository for starting places to help contribute towards, or simply create your own new contribution to the project.

Please make sure to follow the existing standards within the project such as code styles, naming conventions and commenting/documentation.

When you are ready, simply create a pull request for your contribution and I will review it whenever I can!

Donating

You can also help me and the project out by sponsoring me through GitHub Sponsors (preferred), contributing through a donation on PayPal or by supporting me monthly on my Patreon page.

GitHub Sponsors Patreon PayPal

Discussion, Support and Issues

Need support with this project, have found an issue or want to chat with others about contributing to the project?

Please check the project's issues page first for support & bugs!

Not found what you need here?

  • If you have an issue, please create a GitHub issue here to report the situation, include as much detail as you can!
  • or, You can join our Slack workspace to discuss any issue, to get support for the project or to chat with contributors and myself:
Slack