httpzip

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Client

func Client() *resty.Client

func SetClient

func SetClient(c *http.Client)

Types

type File

type File struct {
	// Name 文件名(相对路径),来源于 Central Directory/File Header
	Name string

	// CompressedSize 压缩后的大小(字节数)
	// 对应 Central Directory 中的 compressed size 字段
	CompressedSize uint64

	// UncompressedSize 解压后的大小(字节数)
	// 对应 Central Directory 中的 uncompressed size 字段
	UncompressedSize uint64

	// Compression 压缩算法标识
	// 0 = Store(无压缩),8 = Deflate,其它见 ZIP 规范
	Compression uint16

	// Offset 文件数据在 ZIP 中的偏移量(相对于整个 ZIP 文件的开头)
	// 一般指向对应 Local File Header 的起始位置
	Offset uint64
	// contains filtered or unexported fields
}

File 表示 ZIP 文件中的一个文件条目(Central Directory 中的记录)

func (*File) Open

func (f *File) Open() (io.ReadCloser, error)

Open 打开文件内容,返回一个 io.ReadCloser

type Reader

type Reader struct {
	Size int64
	File []*File
	// contains filtered or unexported fields
}

Reader 远程 ZIP Reader

func NewReader

func NewReader(ctx context.Context, url string) (*Reader, error)

OpenReader 打开远程 ZIP 并解析目录

EOCD(End of Central Directory)

标准ZIP
---------------------------------------------------------
4   bytes   End of central dir signature (0x06054b50)
2   bytes   Number of this disk
2   bytes   Number of the disk with the start of the central directory
2   bytes   Total number of entries in the central directory on this disk
2   bytes   Total number of entries in the central directory
4   bytes   Size of the central directory
4   bytes   Offset of start of central directory with respect to the starting disk number
2   bytes   ZIP file comment length

ZIP64
---------------------------------------------------------
4   bytes   Signature 0x06064b50
8   bytes   Size of zip64 end of central directory record
2   bytes   Version made by
2   bytes   Version needed to extract
4   bytes   Number of this disk
4   bytes   Number of the disk with the start of the central directory
8   bytes   Total number of entries in the central directory on this disk
8   bytes   Total number of entries in the central directory
8   bytes   Size of the central directory
8   bytes   Offset of start of central directory

type ZipCloser

type ZipCloser struct {
	io.Reader
	// contains filtered or unexported fields
}

func (*ZipCloser) Close

func (zc *ZipCloser) Close() error

Jump to

Keyboard shortcuts

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