tar

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2020 License: Apache-2.0 Imports: 20 Imported by: 2

README

tar - tar archives

Usage

  • Service
    service := afs.New()
    ctx := context.Background()
    objects, err := service.List(ctx, "file:/tmp/app.war/tar://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 := tar.NewWalker(file.New())
	err := service.Copy(ctx, "/tmp/test.tar", "mem://dest/folder/test", walker)
	if err != nil {
		log.Fatal(err)
	}
  • Uploader
    ctx := context.Background()
	service := afs.New()
	uploader := tar.NewBatchUploader(file.New())
	err := service.Copy(ctx, "/tmp/test/data", "/tmp/data.tar", uploader)
	if err != nil {
		log.Fatal(err)
	}

Documentation

Overview

Package tar provides support for operating on TAR archives

Index

Examples

Constants

View Source
const Scheme = "tar"

Scheme defines tar 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"
	"github.com/viant/afs"
	"github.com/viant/afs/file"
	"github.com/viant/afs/tar"
	"log"
)

func main() {
	ctx := context.Background()
	service := afs.New()
	uploader := tar.NewBatchUploader(file.New())
	err := service.Copy(ctx, "/tmp/test/data", "/tmp/data.tar", 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(download storage.Opener) storage.Walker

NewWalker returns a walker

Example
package main

import (
	"context"
	"github.com/viant/afs"
	"github.com/viant/afs/file"
	"github.com/viant/afs/tar"
	"log"
)

func main() {
	ctx := context.Background()
	service := afs.New()
	walker := tar.NewWalker(file.New())
	err := service.Copy(ctx, "/tmp/test.tar", "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