zip

package
Version: v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: Apache-2.0 Imports: 18 Imported by: 2

README

zip - zip archives

Usage

  • Service
    service := afs.New()
    ctx := context.Background()
    objects, err := service.List(ctx, "file:/tmp/app.war/zip://localhost/WEB-INF")
    if err != nil {
        log.Fatal(err)
    }
    for _, object := range objects {
        fmt.Printf("%v %v\n", object.Name(), object.URL())
        if object.IsDir() {
            continue
        }
        reader, err := service.Download(ctx, object)
        if err != nil {
            log.Fatal(err)
        }
        data, err := ioutil.ReadAll(reader)
        if err != nil {
            log.Fatal(err)
        }
        fmt.Printf("%s\n", data)
    }
  • Walker
    ctx := context.Background()
	service := afs.New()
	walker := zip.NewWalker(file.New())
	err := service.Copy(ctx, "/tmp/test.zip", "mem://dest/folder/test", walker)
	if err != nil {
		log.Fatal(err)
	}
  • Uploader
    ctx := context.Background()
	service := afs.New()
	uploader := zip.NewBatchUploader(file.New())
	err := service.Copy(ctx, "/tmp/test/data", "/tmp/data.zip", uploader)
	if err != nil {
		log.Fatal(err)
	}

Documentation

Overview

Package zip provides support for operating on ZIP archives

Index

Examples

Constants

View Source
const Scheme = "zip"

Scheme defines zip URL scheme

Variables

This section is empty.

Functions

func New

func New(options ...storage.Option) storage.Manager

New creates zip manager

func NewBatchUploader

func NewBatchUploader(dest storage.Uploader) storage.BatchUploader

NewBatchUploader returns a batch uploader

Example
package main

import (
	"context"
	"log"

	"github.com/viant/afs"
	"github.com/viant/afs/file"
	"github.com/viant/afs/zip"
)

func main() {
	ctx := context.Background()
	service := afs.New()
	uploader := zip.NewBatchUploader(file.New())
	err := service.Copy(ctx, "/tmp/test/data", "/tmp/data.zip", uploader)
	if err != nil {
		log.Fatal(err)
	}
}
Output:

func NewStorager

func NewStorager(ctx context.Context, baseURL string, mgr storage.Manager) (storage.Storager, error)

NewStorager create a storage service

func NewWalker

func NewWalker(downloader storage.Opener) storage.Walker

NewWalker returns a walker

Example
package main

import (
	"context"
	"log"

	"github.com/viant/afs"
	"github.com/viant/afs/file"
	"github.com/viant/afs/zip"
)

func main() {
	ctx := context.Background()
	service := afs.New()
	walker := zip.NewWalker(file.New())
	err := service.Copy(ctx, "/tmp/test.zip", "mem://dest/folder/test", walker)
	if err != nil {
		log.Fatal(err)
	}

}
Output:

func Provider

func Provider(options ...storage.Option) (storage.Manager, error)

Provider returns a http manager

Types

This section is empty.

Jump to

Keyboard shortcuts

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