archiveserver

package
v2.8.0-nightly.20230926 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package archiveserver implements an HTTP server for downloading archives.

See: https://www.notion.so/2023-04-03-HTTP-file-and-archive-downloads-cfb56fac16e54957b015070416b09e94

Index

Constants

View Source
const (
	EncodingVersion1 = uint8(0x01)
)

Variables

This section is empty.

Functions

func Decode

func Decode(r io.Reader) (io.Reader, uint8, error)

Decode begins the decoding process; all versions are base64url-encoded bytes prefixed with a uint8 version number. Decode returns a reader of the bytes right after the version, and the version number.

func DecodeV1

func DecodeV1(r io.Reader) (*bufio.Scanner, error)

DecodeV1 returns a bufio.Scanner that returns each encoded path. The reader should already be read past the version number; Decode() above does exactly this.

func DecodeV1Path

func DecodeV1Path(path string) (*pfs.File, error)

DecodeV1Path decodes a V1 path. pachctl's convention of branch=commit is not supported.

func EncodeV1

func EncodeV1(paths []string) (string, error)

EncodeV1 generates a V1 archive URL string.

Types

type ArchiveFormat

type ArchiveFormat string

ArchiveFormat is the file format to produce.

const (
	ArchiveFormatZip ArchiveFormat = "zip" // A ZIP file.
)

func (ArchiveFormat) ContentType

func (f ArchiveFormat) ContentType() string

type ArchiveRequest

type ArchiveRequest struct {
	Format ArchiveFormat // The desired format of the archive.
	// contains filtered or unexported fields
}

An ArchiveRequest is a valid archive download URL.

func ArchiveFromURL

func ArchiveFromURL(u *url.URL) (*ArchiveRequest, error)

ArchiveFromURL parses a URL into an ArchiveRequest.

func (*ArchiveRequest) ForEachPath

func (req *ArchiveRequest) ForEachPath(cb func(path string) error) error

ForEachPath calls the callback with each requested file.

type Server

type Server struct {
	ClientFactory func(context.Context) *client.APIClient
}

Server is an http.Handler that can download archives of PFS files.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP implements http.Handler for the /archive/ route.

Jump to

Keyboard shortcuts

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