Javascript library to create or read tar files in the browser
It is often necessary to pack data into single files in the browser (e.g. creating a "project" file consisting of images+data in WebPlotDigitizer). One way is to create simple tarballs with all the data. There are a few existing libraries that do this, but this seems easy enough to do so I decided to do make my own library for learning purposes.
Refer to https://www.npmjs.com/package/@gera2ld/tarjs for a better maintained version of this code. This code is mainly used to support WebPlotDigitizer.
There are a few known limitations with this library:
- Browser only, no support for NodeJS.
- File name (including path) has to be less than 100 characters.
- Maximum total file size seems to be limited to somewhere between 500MB to 1GB (exact limit is unknown).
Some benefits of using this library:
- Code is a lot cleaner than most other implementations that I can find.
- Unit tests for read and write.
This works fine on any recent version of Chrome, Firefox or Safari.
For Chrome, the test page has to be hosted on a HTTP server. An easy way is to use Python:
In the root directory of this project, do:
python3 -m http.server 8000
Then browse to http://localhost:8000/tests/
In Firefox, you can simply load tests/index.html without starting a web server.
- https://github.com/beatgammit/tar-js
- https://github.com/chriswininger/jstar
- https://github.com/InvokIT/js-untar (reading only)
- https://github.com/workhorsy/uncompress.js (reading only)
- http://stuk.github.io/jszip/ (active and well maintained project but for .zip files)
If you are aware of other implementations, then please let me know :)