Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrUnsupportedVersion = errors.New("unsupported version") ErrMaxSizeExceeded = errors.New("maximum size exceeded") ErrInvalidContentType = errors.New("missing or invalid Content-Type header") ErrInvalidUploadLength = errors.New("missing or invalid Upload-Length header") ErrInvalidOffset = errors.New("missing or invalid Upload-Offset header") ErrNotFound = errors.New("upload not found") ErrFileLocked = errors.New("file currently locked") ErrMismatchOffset = errors.New("mismatched 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 Upload-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, ErrInvalidContentType: http.StatusBadRequest, ErrInvalidUploadLength: http.StatusBadRequest, ErrInvalidOffset: http.StatusBadRequest, ErrNotFound: http.StatusNotFound, ErrFileLocked: 423, ErrMismatchOffset: 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 // Initiate the CompleteUploads channel in the Handler struct in order to // be notified about complete uploads NotifyCompleteUploads bool // Logger the logger to use internally Logger *log.Logger }
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. // The function call must return the number of bytes written. WriteChunk(id string, offset int64, src io.Reader) (int64, 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. // If the returned reader also implements the io.Closer interface, the // Close() method will be invoked once everything has been read. 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 { // For each finished upload the corresponding info object will be sent using // this unbuffered channel. The NotifyCompleteUploads property in the Config // struct must be set to true in order to work. CompleteUploads chan FileInfo // contains filtered or unexported fields }
func NewHandler ¶
Create a new handler using the given configuration.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
FileStore is a storage backend used as a tusd.DataStore in tusd.NewHandler.
|
FileStore is a storage backend used as a tusd.DataStore in tusd.NewHandler. |
Package limitedstore implements a simple wrapper around existing datastores (tusd.DataStore) while limiting the used storage size.
|
Package limitedstore implements a simple wrapper around existing datastores (tusd.DataStore) while limiting the used storage size. |
Click to show internal directories.
Click to hide internal directories.