Documentation
¶
Overview ¶
Package seektar dynamically generates tarballs in a deterministic way that allows seeking. This can be used on servers to provide downloads for an entire directory, while still supporting Byte-Range HTTP requests.
Example:
tarResult, _ := seektar.Tar("/path/to/directory", "directory")
tarFile, _ := tarResult.Open()
defer tarFile.Close()
// tarFile is an io.Reader, io.Seeker, and io.Closer.
// It dynamically generates tar data.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agg ¶
type Agg []Piece
An Agg is a Piece that combines other Pieces.
func Tar ¶
Tar generates a tarball as a Piece.
If prefix is specified, then it is used as a directory name for the tarred content. Otherwise, the tarred content is stored relative to the root of the archive.
The result is deterministic, provided that the contents of the directory do not change.
func TarFile ¶
TarFile generates a tarball containing a single file.
The name argument specifies the name to give the file within the archive. It should use the '/' path separator.
func TarHTTP ¶
func TarHTTP(vfs http.FileSystem, dirPath, prefix string) (agg Agg, err error)
TarHTTP is like Tar, but for an http.FileSystem.
func TarHTTPFile ¶
TarHTTPFile generates a tarball containing a single file in an http.FileSystem.
func (Agg) Open ¶
func (a Agg) Open() (ReadSeekCloser, error)
type BytePiece ¶
type BytePiece []byte
A BytePiece is a Piece of pre-defined data.
func (BytePiece) Open ¶
func (b BytePiece) Open() (ReadSeekCloser, error)
type FilePiece ¶
type FilePiece struct {
// contains filtered or unexported fields
}
A FilePiece is a Piece that is stored in a file.
func NewFilePiece ¶
NewFilePiece creates a FilePiece for a file on disk.
func (*FilePiece) Open ¶
func (f *FilePiece) Open() (ReadSeekCloser, error)
type HTTPFilePiece ¶
type HTTPFilePiece struct {
// contains filtered or unexported fields
}
An HTTPFilePiece is a Piece that is stored in a file in an http.FileSsytem.
func NewHTTPFilePiece ¶
func NewHTTPFilePiece(path string, fs http.FileSystem) (*HTTPFilePiece, error)
NewHTTPFilePiece creates an HTTPFilePiece for a file on an http.FileSystem.
func (*HTTPFilePiece) HashID ¶
func (f *HTTPFilePiece) HashID() []byte
func (*HTTPFilePiece) Open ¶
func (f *HTTPFilePiece) Open() (ReadSeekCloser, error)
func (*HTTPFilePiece) Size ¶
func (f *HTTPFilePiece) Size() int64
type Piece ¶
type Piece interface {
Size() int64
HashID() []byte
Open() (ReadSeekCloser, error)
}
A Piece represents a piece of a tarball.
type ReadSeekCloser ¶
type ReadSeekCloser interface {
io.Closer
io.ReadSeeker
}
type TarTypeFlag ¶
type TarTypeFlag byte
const ( NormalFile TarTypeFlag = '0' Directory TarTypeFlag = '5' Symlink TarTypeFlag = '2' )