storagearchive

package
v0.0.0-...-a078c60 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package storagearchive implements archive utilities.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFileSizeLimit is returned when file read limit is reached.
	//
	// See [WithMaxFileSizeUntarOption]
	ErrFileSizeLimit = errors.New("file size exceeded read limit")
)

Functions

func Tar

func Tar(
	ctx context.Context,
	readBucket storage.ReadBucket,
	writer io.Writer,
) (retErr error)

Tar tars the given bucket to the writer.

Only regular files are added to the writer. All files are written as 0644.

func Untar

func Untar(
	ctx context.Context,
	reader io.Reader,
	writeBucket storage.WriteBucket,
	mapper storage.Mapper,
	stripComponentCount uint32,
	opts ...UntarOption,
) error

Untar untars the given tar archive from the reader into the bucket.

Only regular files are added to the bucket.

Paths from the tar archive will be mapped before adding to the bucket. Mapper can be nil. StripComponents happens before the mapper.

func Unzip

func Unzip(
	ctx context.Context,
	readerAt io.ReaderAt,
	size int64,
	writeBucket storage.WriteBucket,
	mapper storage.Mapper,
	stripComponentCount uint32,
) error

Unzip unzips the given zip archive from the reader into the bucket.

Only regular files are added to the bucket.

Paths from the zip archive will be mapped before adding to the bucket. Mapper can be nil. StripComponents happens before the mapper.

func Zip

func Zip(
	ctx context.Context,
	readBucket storage.ReadBucket,
	writer io.Writer,
	compressed bool,
) (retErr error)

Zip zips the given bucket to the writer.

Only regular files are added to the writer.

Types

type UntarOption

type UntarOption interface {
	// contains filtered or unexported methods
}

UntarOption is an option for Untar.

func WithMaxFileSizeUntarOption

func WithMaxFileSizeUntarOption(size int) UntarOption

WithMaxFileSizeUntarOption returns an option that limits the maximum size

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL