zachary-kuhn / zipstream

Reads zip files from io.Reader

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ZipStream

Enables zip file streaming from an io.Reader. Now with ZIP64 support.

Example

package main

import (
	"github.com/dbregman/zipstream"
	"bytes"
	"io"
	"log"
	"io/ioutil"
	)

func main() {
	// Read the first compressed file from a zip file.
	var zipFile bytes.Buffer
	zr := zipstream.NewReader(&zipFile)
	meta, err := zr.Next()
	if err != nil {
		if err != io.EOF {
			panic(err)
		}
	}
	log.Printf("file name: %s", meta.Name)
	compressedFile, err := ioutil.ReadAll(zr)
	if err != nil {
		panic(err)
	}
	log.Printf("file content: %s", string(compressedFile[:]))
}

History

golang/go#10568

About

Reads zip files from io.Reader

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Go 100.0%