Versions in this module Expand all Collapse all v1 v1.6.1 May 17, 2021 Changes in this version + const UploadLengthDeferred + var ErrFileLocked = NewHTTPError(errors.New("file currently locked"), 423) + var ErrInvalidConcat = NewHTTPError(errors.New("invalid Upload-Concat header"), http.StatusBadRequest) + var ErrInvalidContentType = NewHTTPError(errors.New("missing or invalid Content-Type header"), http.StatusBadRequest) + var ErrInvalidOffset = NewHTTPError(errors.New("missing or invalid Upload-Offset header"), http.StatusBadRequest) + var ErrInvalidUploadDeferLength = NewHTTPError(errors.New("invalid Upload-Defer-Length header"), http.StatusBadRequest) + var ErrInvalidUploadLength = NewHTTPError(errors.New("missing or invalid Upload-Length header"), http.StatusBadRequest) + var ErrMaxSizeExceeded = NewHTTPError(errors.New("maximum size exceeded"), http.StatusRequestEntityTooLarge) + var ErrMismatchOffset = NewHTTPError(errors.New("mismatched offset"), http.StatusConflict) + var ErrModifyFinal = NewHTTPError(errors.New("modifying a final upload is not allowed"), http.StatusForbidden) + var ErrNotFound = NewHTTPError(errors.New("upload not found"), http.StatusNotFound) + var ErrNotImplemented = NewHTTPError(errors.New("feature not implemented"), http.StatusNotImplemented) + var ErrSizeExceeded = NewHTTPError(errors.New("resource's size exceeded"), http.StatusRequestEntityTooLarge) + var ErrUnsupportedVersion = NewHTTPError(errors.New("unsupported version"), http.StatusPreconditionFailed) + var ErrUploadLengthAndUploadDeferLength = NewHTTPError(errors.New("provided both Upload-Length and Upload-Defer-Length"), ...) + var ErrUploadNotFinished = NewHTTPError(errors.New("one of the partial uploads is not finished"), ...) + var ErrUploadStoppedByServer = NewHTTPError(errors.New("upload has been stopped by server"), http.StatusBadRequest) + func LogEvent(logger *log.Logger, eventName string, details ...string) + func ParseMetadataHeader(header string) map[string]string + func SerializeMetadataHeader(meta map[string]string) string + type ConcatableUpload interface + ConcatUploads func(ctx context.Context, partialUploads []Upload) error + type ConcaterDataStore interface + AsConcatableUpload func(upload Upload) ConcatableUpload + type Config struct + BasePath string + Logger *log.Logger + MaxSize int64 + NotifyCompleteUploads bool + NotifyCreatedUploads bool + NotifyTerminatedUploads bool + NotifyUploadProgress bool + PreFinishResponseCallback func(hook HookEvent) error + PreUploadCreateCallback func(hook HookEvent) error + RespectForwardedHeaders bool + StoreComposer *StoreComposer + type DataStore interface + GetUpload func(ctx context.Context, id string) (upload Upload, err error) + NewUpload func(ctx context.Context, info FileInfo) (upload Upload, err error) + type ErrorsTotalMap struct + func (e *ErrorsTotalMap) Load() map[HTTPError]*uint64 + type FileInfo struct + ID string + IsFinal bool + IsPartial bool + MetaData MetaData + Offset int64 + PartialUploads []string + Size int64 + SizeIsDeferred bool + Storage map[string]string + func (f FileInfo) StopUpload() + type HTTPError interface + Body func() []byte + StatusCode func() int + func NewHTTPError(err error, statusCode int) HTTPError + type HTTPRequest struct + Header http.Header + Method string + RemoteAddr string + URI string + type Handler struct + func NewHandler(config Config) (*Handler, error) + type HookEvent struct + HTTPRequest HTTPRequest + Upload FileInfo + type LengthDeclarableUpload interface + DeclareLength func(ctx context.Context, length int64) error + type LengthDeferrerDataStore interface + AsLengthDeclarableUpload func(upload Upload) LengthDeclarableUpload + type Lock interface + Lock func() error + Unlock func() error + type Locker interface + NewLock func(id string) (Lock, error) + type MetaData map[string]string + type Metrics struct + BytesReceived *uint64 + ErrorsTotal *ErrorsTotalMap + RequestsTotal map[string]*uint64 + UploadsCreated *uint64 + UploadsFinished *uint64 + UploadsTerminated *uint64 + type StoreComposer struct + Concater ConcaterDataStore + Core DataStore + LengthDeferrer LengthDeferrerDataStore + Locker Locker + Terminater TerminaterDataStore + UsesConcater bool + UsesLengthDeferrer bool + UsesLocker bool + UsesTerminater bool + func NewStoreComposer() *StoreComposer + func (store *StoreComposer) Capabilities() string + func (store *StoreComposer) UseConcater(ext ConcaterDataStore) + func (store *StoreComposer) UseCore(core DataStore) + func (store *StoreComposer) UseLengthDeferrer(ext LengthDeferrerDataStore) + func (store *StoreComposer) UseLocker(ext Locker) + func (store *StoreComposer) UseTerminater(ext TerminaterDataStore) + type TerminatableUpload interface + Terminate func(ctx context.Context) error + type TerminaterDataStore interface + AsTerminatableUpload func(upload Upload) TerminatableUpload + type UnroutedHandler struct + CompleteUploads chan HookEvent + CreatedUploads chan HookEvent + Metrics Metrics + TerminatedUploads chan HookEvent + UploadProgress chan HookEvent + func NewUnroutedHandler(config Config) (*UnroutedHandler, error) + func (handler *UnroutedHandler) DelFile(w http.ResponseWriter, r *http.Request) + func (handler *UnroutedHandler) GetFile(w http.ResponseWriter, r *http.Request) + func (handler *UnroutedHandler) HeadFile(w http.ResponseWriter, r *http.Request) + func (handler *UnroutedHandler) Middleware(h http.Handler) http.Handler + func (handler *UnroutedHandler) PatchFile(w http.ResponseWriter, r *http.Request) + func (handler *UnroutedHandler) PostFile(w http.ResponseWriter, r *http.Request) + func (handler *UnroutedHandler) SupportedExtensions() string + type Upload interface + FinishUpload func(ctx context.Context) error + GetInfo func(ctx context.Context) (FileInfo, error) + GetReader func(ctx context.Context) (io.Reader, error) + WriteChunk func(ctx context.Context, offset int64, src io.Reader) (int64, error)