Documentation ¶
Overview ¶
Package storagearchive implements archive utilities.
Index ¶
- Variables
- func Tar(ctx context.Context, readBucket storage.ReadBucket, writer io.Writer) (retErr error)
- func Untar(ctx context.Context, reader io.Reader, writeBucket storage.WriteBucket, ...) error
- func Unzip(ctx context.Context, readerAt io.ReaderAt, size int64, ...) error
- func Zip(ctx context.Context, readBucket storage.ReadBucket, writer io.Writer, ...) (retErr error)
- type UntarOption
- type UnzipOption
Constants ¶
This section is empty.
Variables ¶
var ( // ErrFileSizeLimit is returned when file read limit is reached. // // See [WithMaxFileSizeUntarOption] ErrFileSizeLimit = errors.New("file size exceeded read limit") )
Functions ¶
func Tar ¶
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.
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.