devportal

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArchiveReader

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

ArchiveReader processes a Zip archive, dispatching handling of the index and blobs to supplied callbacks

func NewArchiveReader

func NewArchiveReader(filename string) (a ArchiveReader, err error)

NewArchiveReader returns an ArchiveReader configured to process the supplied archive filename

func (*ArchiveReader) Close

func (a *ArchiveReader) Close() error

Close the underlying Zip file reader. Further operations on the ArchiveReader are invalid

func (*ArchiveReader) Process

func (a *ArchiveReader) Process() error

Process the archive, dispatching to callbacks to handle the index and blobs

func (ArchiveReader) WithBlobHandler

func (a ArchiveReader) WithBlobHandler(h BlobHandler) ArchiveReader

WithBlobHandler returns a new ArchiveReader configured with a callback handler that Process() will dispatch to when it encounters a Blob

func (ArchiveReader) WithIndexHandler

func (a ArchiveReader) WithIndexHandler(h IndexHandler) ArchiveReader

WithIndexHandler returns a new ArchiveReader configured with a callback handler that Process() will dispatch to for the data.json index

type ArchiveWriter

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

ArchiveWriter writes a Zip archive file by processing Blobs from an Azure Storage account, and an index (content items)

func NewArchiveWriter

func NewArchiveWriter(filename string) (*ArchiveWriter, error)

NewArchiveWriter returns a new ArchiveWriter ready to write Blobs and an index to the supplied file

Caller MUST run Close() on the ArchiveWriter or data will be lost

func (*ArchiveWriter) AddBlob

func (a *ArchiveWriter) AddBlob(url azblob.BlobURL) error

AddBlob copies the Blob from the supplied Azure storage account URL to the underlying archive

func (*ArchiveWriter) AddContentItems added in v0.1.1

func (a *ArchiveWriter) AddContentItems(data []byte) error

AddContentItems writes the content items (index) JSON to the archive as data.json

func (*ArchiveWriter) Close

func (a *ArchiveWriter) Close() error

Close closes the Zip archive, and MUST be called to prevent data loss

type BlobHandler

type BlobHandler func(name string, f ZipReadSeeker) error

BlobHandler defines a function prototype that handles blobs as they are read from the archive

type IndexHandler

type IndexHandler func(f ZipReadSeeker) error

IndexHandler defines a function prototype that handles an archive 'index' (data.json) as it is read from the archive

type ZipReadSeeker

type ZipReadSeeker struct {
	io.ReadCloser
	// contains filtered or unexported fields
}

ZipReadSeeker is a wrapper around an io.ReadCloser, providing additional functionality to emulate Seek(), thus also implementing Seeker() and making ZipReadSeeker a ReaderSeeker

func (*ZipReadSeeker) Read

func (z *ZipReadSeeker) Read(b []byte) (n int, err error)

func (*ZipReadSeeker) Seek

func (z *ZipReadSeeker) Seek(offset int64, whence int) (absOffset int64, err error)

Seek to offset within the Zip file. Implements io.Seeker, but will close and re-open the file if the new offset is before the current offset

Jump to

Keyboard shortcuts

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