windlass

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

README

windlass

A Go library for multipart file uploads.

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

Features

  • Resumable multipart uploads.
  • All metadata is stored in the filesystem.
  • No database required.

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 upload_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 reslient upload client.

func NewClient

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

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 we can upload chunks 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
	// Timeout is the timeout to use when making requests (eg. dialing, TLS handshake, etc).
	Timeout time.Duration
	// MaxRetryAttempts is the maximum number of times to retry a failed request.
	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 {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(logger *slog.Logger, fs writablefs.FS) *Server

func (*Server) Close

func (s *Server) Close() error

func (*Server) ServeHTTP

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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