upload

package
v9.1.53+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2020 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const DefaultUploadConcurrency = 3

DefaultUploadConcurrency is the default number of goroutines to spin up when using Upload().

View Source
const DefaultUploadPartSize = MinUploadPartSize

DefaultUploadPartSize is the default part size to buffer chunks of a payload into.

View Source
const MaxUploadParts = 10000

MaxUploadParts is the maximum allowed number of parts in a multi-part upload on Amazon S3.

View Source
const MinUploadPartSize int64 = 1024 * 1024 * 5

MinUploadPartSize is the minimum allowed part size when uploading a part to Amazon S3.

Variables

View Source
var ErrDeadlineReached = errors.New("upload: deadline reached trying to upload")

ErrDeadlineReached is an error returned if the Deadline is reached

Functions

func Upload

func Upload(opts Options) (int, int64, error)

Upload a file to the upload server in multi part upload returns the number of parts, the total size in bytes of the upload and an optional error (nil if none)

Types

type Options

type Options struct {
	// APIKey is required for communication
	APIKey string

	// The buffer size (in bytes) to use when buffering data into chunks and
	// sending them as parts to S3. The minimum allowed part size is 5MB, and
	// if this value is set to zero, the DefaultUploadPartSize value will be used.
	PartSize int64

	// The number of goroutines to spin up in parallel per call to Upload when
	// sending parts. If this is set to zero, the DefaultUploadConcurrency value
	// will be used.
	//
	// The concurrency pool is not shared between calls to Upload.
	Concurrency int

	// Body is the content to upload. It's the responsibility of the caller to close this reader itself
	Body io.Reader

	// ContentType is the body content type
	ContentType string

	// URL to upload the parts to
	URL string

	// HTTPClientConfig is a custom httpclient.Config in case you want to override the behavior
	HTTPClientConfig *httpclient.Config

	// Deadline is the time by which the upload (or any part) should have finished before returning ErrDeadlineReached
	// defaults to 10 minutes if not provided
	Deadline time.Time
}

Options for configuring the upload

Jump to

Keyboard shortcuts

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