windlass

package module
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: MPL-2.0 Imports: 32 Imported by: 0

README

windlass

A library for multipart file uploads/downloads.

Inspired by tus and S3 multipart upload but with a no-nonsense approach.

Features

  • Resumable multipart uploads.
  • All metadata is stored in the filesystem.
  • Partial file downloads.
  • Directory downloads.

Usage

See server.go for how to implement a windlass server.

Information about how to use the windlass client can be found in the end-to-end tests in windlass_test.go.

Clients

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a client for uploading and downloading files from a windlass server.

func NewClient

func NewClient(logger *slog.Logger, baseURL string, opts *ClientOptions) (*Client, error)

NewClient creates a new windlass client.

func (*Client) Download added in v0.9.1

func (c *Client) Download(ctx context.Context, path string, w io.Writer) error

Download downloads a file from the server.

func (*Client) Upload

func (c *Client) Upload(ctx context.Context, path string, r io.ReaderAt, size int64) error

Upload uploads a file to the server, you must provide a ReaderAt so that chunks can be read concurrently.

type ClientOptions

type ClientOptions struct {
	// NumConnections is the number of concurrent connections to use when uploading chunks.
	NumConnections int
	// ChunkSizeBytes is the size of each chunk.
	ChunkSizeBytes int64
	// MaxRetryAttempts is the maximum number of retry attempts to make before giving up.
	MaxRetryAttempts int
	// TLSClientConfig is the optional TLS configuration to use when making requests.
	TLSClientConfig *tls.Config
}

ClientOptions are options for configuring the behavior of the upload client.

type Server

type Server struct {
	http.Handler
	// contains filtered or unexported fields
}

Server is a windlass server.

func NewServer

func NewServer(logger *slog.Logger, fsys writablefs.FS, opts ...ServerOption) *Server

NewServer creates a new windlass server.

func (*Server) Routes added in v0.10.0

func (s *Server) Routes() []string

Routes returns the routes that the server is handling. This is for integration with other routers.

type ServerOption added in v0.7.0

type ServerOption func(*serverConfig)

ServerOption is an option for configuring a windlass server.

func WithStagingFS added in v0.7.2

func WithStagingFS(fsys writablefs.FS) ServerOption

WithStagingFS sets the staging filesystem to use for storing partial uploads. If not provided, the target filesystem will be used. This is useful for filesystems that only support immutable files, such as S3.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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