storagearchive

package
v1.32.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: Apache-2.0 Imports: 13 Imported by: 6

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,
	options ...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,
	options ...UnzipOption,
) 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 added in v1.9.0

type UntarOption func(*untarOptions)

UntarOption is an option for Untar.

func UntarWithFilePathMatcher added in v1.32.0

func UntarWithFilePathMatcher(filePathMatcher func(string) bool) UntarOption

UntarWithFilePathMatcher returns a new UntarOption that will only write a given file to the bucket if the function returns true on the normalized file path.

The matcher will be applied after components are stripped.

func UntarWithMaxFileSize added in v1.32.0

func UntarWithMaxFileSize(maxFileSize int64) UntarOption

UntarWithMaxFileSize returns a new UntarOption that limits the maximum file size.

The default is to have no limit.

func UntarWithStripComponentCount added in v1.32.0

func UntarWithStripComponentCount(stripComponentCount uint32) UntarOption

UntarWithStripComponentCount returns a new UntarOption that strips the specified number of components.

type UnzipOption added in v1.32.0

type UnzipOption func(*unzipOptions)

UnzipOption is an option for Unzip.

func UnzipWithFilePathMatcher added in v1.32.0

func UnzipWithFilePathMatcher(filePathMatcher func(string) bool) UnzipOption

UnzipWithFilePathMatcher returns a new UnzipOption that will only write a given file to the bucket if the function returns true on the normalized file path.

The matcher will be applied after components are stripped.

func UnzipWithStripComponentCount added in v1.32.0

func UnzipWithStripComponentCount(stripComponentCount uint32) UnzipOption

UnzipWithStripComponentCount returns a new UnzipOption that strips the specified number of components.

Jump to

Keyboard shortcuts

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