Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrUnsupportedVersion = errors.New("unsupported version") ErrMaxSizeExceeded = errors.New("maximum size exceeded") ErrInvalidEntityLength = errors.New("missing or invalid Entity-Length header") ErrInvalidOffset = errors.New("missing or invalid Offset header") ErrNotFound = errors.New("upload not found") ErrFileLocked = errors.New("file currently locked") ErrIllegalOffset = errors.New("illegal offset") ErrSizeExceeded = errors.New("resource's size exceeded") ErrNotImplemented = errors.New("feature not implemented") ErrUploadNotFinished = errors.New("one of the partial uploads is not finished") ErrInvalidConcat = errors.New("invalid Concat header") ErrModifyFinal = errors.New("modifying a final upload is not allowed") )
View Source
var ErrStatusCodes = map[error]int{ ErrUnsupportedVersion: http.StatusPreconditionFailed, ErrMaxSizeExceeded: http.StatusRequestEntityTooLarge, ErrInvalidEntityLength: http.StatusBadRequest, ErrInvalidOffset: http.StatusBadRequest, ErrNotFound: http.StatusNotFound, ErrFileLocked: 423, ErrIllegalOffset: http.StatusConflict, ErrSizeExceeded: http.StatusRequestEntityTooLarge, ErrNotImplemented: http.StatusNotImplemented, ErrUploadNotFinished: http.StatusBadRequest, ErrInvalidConcat: http.StatusBadRequest, ErrModifyFinal: http.StatusForbidden, }
HTTP status codes sent in the response when the specific error is returned.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // DataStore implementation used to store and retrieve the single uploads. // Must no be nil. DataStore DataStore // MaxSize defines how many bytes may be stored in one single upload. If its // value is is 0 or smaller no limit will be enforced. MaxSize int64 // BasePath defines the URL path used for handling uploads, e.g. "/files/". // If no trailing slash is presented it will be added. You may specify an // absolute URL containing a scheme, e.g. "http://tus.io" BasePath string }
type DataStore ¶
type DataStore interface { // Create a new upload using the size as the file's length. The method must // return an unique id which is used to identify the upload. If no backend // (e.g. Riak) specifes the id you may want to use the uid package to // generate one. The properties Size and MetaData will be filled. NewUpload(info FileInfo) (id string, err error) // Write the chunk read from src into the file specified by the id at the // given offset. The handler will take care of validating the offset and // limiting the size of the src to not overflow the file's size. It may // return an os.ErrNotExist which will be interpretet as a 404 Not Found. // It will also lock resources while they are written to ensure only one // write happens per time. WriteChunk(id string, offset int64, src io.Reader) error // Read the fileinformation used to validate the offset and respond to HEAD // requests. It may return an os.ErrNotExist which will be interpretet as a // 404 Not Found. GetInfo(id string) (FileInfo, error) // Get an io.Reader to allow downloading the file. This feature is not // part of the official tus specification. If this additional function // should not be enabled any call to GetReader should return // tusd.ErrNotImplemented. The length of the resource is determined by // retrieving the offset using GetInfo. GetReader(id string) (io.Reader, error) // Terminate an upload so any further requests to the resource, both reading // and writing, must return os.ErrNotExist or similar. Terminate(id string) error }
type FileInfo ¶
type FileInfo struct { Id string // Total file size in bytes specified in the NewUpload call Size int64 // Offset in bytes (zero-based) Offset int64 MetaData MetaData // Indicates that this is a partial upload which will later be used to form // a final upload by concatenation. Partial uploads should not be processed // when they are finished since they are only incomplete chunks of files. IsPartial bool // Indicates that this is a final upload IsFinal bool // If the upload is a final one (see IsFinal) this will be a non-empty // ordered slice containing the ids of the uploads of which the final upload // will consist after concatenation. PartialUploads []string }
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
Create a new handler using the given configuration.
Click to show internal directories.
Click to hide internal directories.