Overview
A TransformStream to create a tar archive. Tar archives allow for storing multiple files in a single file (called an archive, or sometimes a tarball). These archives typically have a single '.tar' extension. This implementation follows the FreeBSD 15.0 spec.
File Format & Limitations
The ustar file format is used for creating the tar archive. While this format is compatible with most tar readers, the format has several limitations, including:
- Paths must be at most 256 characters.
- Files must be at most 8 GiBs in size, or 64 GiBs if
sizeExtension
is set to true. - Sparse files are not supported.
Usage
TarStream may throw an error for several reasons. A few of those are:
- The path is invalid.
- The size provided does not match that of the iterable's length.
Compression
Tar archives are not compressed by default. If you'd like to compress the archive, you may do so by piping it through a compression stream.
Usage
Usage
import { TarStream, type TarStreamInput } from "@std/tar/tar-stream"; await ReadableStream.from<TarStreamInput>([ { type: "directory", path: 'potato/' }, { type: "file", path: 'deno.json', size: (await Deno.stat('deno.json')).size, readable: (await Deno.open('deno.json')).readable }, { type: "file", path: '.vscode/settings.json', size: (await Deno.stat('.vscode/settings.json')).size, readable: (await Deno.open('.vscode/settings.json')).readable } ]) .pipeThrough(new TarStream()) .pipeThrough(new CompressionStream('gzip')) .pipeTo((await Deno.create('./out.tar.gz')).writable)
readable: ReadableStream<Uint8Array>
The ReadableStream
writable: WritableStream<TarStreamInput>
The WritableStream