Documentation
¶
Index ¶
- func Unzip(ctx context.Context, src string, dest string, maxFileSize int64) error
- func ZipInMemory(ctx context.Context, writer func(context.Context, *zip.Writer) error) (*bytes.Buffer, error)
- func ZipSrcData(filename string, data []byte) func(context.Context, *zip.Writer) error
- func ZipSrcDir(src string, dest string) func(context.Context, *zip.Writer) error
- func ZipSrcMap(src map[string]string) func(context.Context, *zip.Writer) error
- func ZipToFile(ctx context.Context, writer func(context.Context, *zip.Writer) error, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Unzip ¶
Unzip extracts the contents of the ZIP file at src into the directory dest. The function enforces a maximum file size for entries, returning an error if any file exceeds maxFileSize. Directories and files are recreated with their original permissions. Any extraction or filesystem error is returned.
func ZipInMemory ¶
func ZipInMemory(ctx context.Context, writer func(context.Context, *zip.Writer) error) (*bytes.Buffer, error)
ZipInMemory creates a ZIP archive entirely in memory and returns the resulting bytes.Buffer. The provided writer function is invoked to populate the archive.
func ZipSrcData ¶
ZipSrcData returns a writer function that writes the provided data as a single file in the ZIP archive using the given filename. A file header is created with the current modification time, and the resulting file entry is written to the provided zip.Writer.
func ZipSrcDir ¶
ZipSrcDir returns a writer function that walks the directory tree rooted at src and adds all files and subdirectories into the provided zip.Writer. The relative paths of files are preserved, and the resulting entries are written to the ZIP archive. The root directory itself and the destination ZIP file (if inside the tree) are skipped.
func ZipSrcMap ¶
ZipSrcMap returns a writer function that adds the files specified in the src map into the provided zip.Writer. Keys represent absolute paths to files, while values represent the directory structure within the ZIP archive. The function ensures directories are created inside the archive before writing their corresponding files.
Types ¶
This section is empty.