zipfs

package
v0.0.0-...-60192f8 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package zipfs provides tools to serve content directly from a zip file to an HTTP response. It also provides the necessary tooling to perform changes on an existing zip file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPZipFile

type HTTPZipFile string

HTTPZipFile serves a zip file as an HTTP directory (without listing) It properly handles If-Modified-Since header and can serve the compressed content when deflate is in Accept-Encoding and the content is compressed with deflate.

func (HTTPZipFile) ServeHTTP

func (f HTTPZipFile) ServeHTTP(w http.ResponseWriter, r *http.Request, options ...serveOption)

type ZipRW

type ZipRW struct {
	// contains filtered or unexported fields
}

ZipRW is a very simple wrapper around zip.Reader and zip.Writer. It can be used as a simple zip file creator or as a tool to copy files from one zip file to another.

func NewZipRW

func NewZipRW(dst io.Writer, src io.ReaderAt, srcSize int64) *ZipRW

NewZipRW returns a new ZipRW using a destination writer and a source reader. Both can be null but, obviously, it won't work very well with at least a writer.

func (*ZipRW) Add

func (z *ZipRW) Add(h *zip.FileHeader, r io.Reader) error

Add adds a new file to the zip file. It creates the necessary directories if needed.

func (*ZipRW) AddDestFile

func (z *ZipRW) AddDestFile(name string) (err error)

AddDestFile adds a destination file to ZipRW.

func (*ZipRW) AddSourceFile

func (z *ZipRW) AddSourceFile(name string) (err error)

AddSourceFile adds a source file to ZipRW.

func (*ZipRW) Close

func (z *ZipRW) Close() error

Close closes all writer resources, including the underlying io.Writer and io.Reader when they implement their respective closer interfaces.

func (*ZipRW) Copy

func (z *ZipRW) Copy(name string) error

Copy copies the content of the file in the source to the destination.

func (*ZipRW) Source

func (z *ZipRW) Source() *zip.Reader

Source returns the underlying source zip.Reader.

func (*ZipRW) SrcFiles

func (z *ZipRW) SrcFiles() []*zip.File

SrcFiles returns a list of zip.File from the source.

Jump to

Keyboard shortcuts

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