Get desktop application:
View/edit binary Protocol Buffers messages
The hook service definition.
InvokeHook is invoked for every hook that is executed. HookRequest contains the corresponding information about the hook type, the involved upload, and causing HTTP request. The return value HookResponse allows to stop or reject an upload, as well as modifying the HTTP response. See the documentation for HookResponse for more details.
HookRequest contains the information about the hook type, the involved upload, and causing HTTP request.
Type is the name of the hook.
Event contains the involved upload and causing HTTP request.
HookResponse is the response after a hook is executed.
HTTPResponse's fields can be filled to modify the HTTP response. This is only possible for pre-create, pre-finish and post-receive hooks. For other hooks this value is ignored. If multiple hooks modify the HTTP response, a later hook may overwrite the modified values from a previous hook (e.g. if multiple post-receive hooks are executed). Example usages: Send an error to the client if RejectUpload/StopUpload are set in the pre-create/post-receive hook. Send more information to the client in the pre-finish hook.
RejectUpload will cause the upload to be rejected and not be created during POST request. This value is only respected for pre-create hooks. For other hooks, it is ignored. Use the HTTPResponse field to send details about the rejection to the client.
ChangeFileInfo can be set to change selected properties of an upload before it has been created. See the handler.FileInfoChanges type for more details. Changes are applied on a per-property basis, meaning that specifying just one property leaves all others unchanged. This value is only respected for pre-create hooks.
StopUpload will cause the upload to be stopped during a PATCH request. This value is only respected for post-receive hooks. For other hooks, it is ignored. Use the HTTPResponse field to send details about the stop to the client.
Event represents an event from tusd which can be handled by the application.
Used in:
Upload contains information about the upload that caused this hook to be fired.
HTTPRequest contains details about the HTTP request that reached tusd.
FileInfo contains information about a single upload resource.
Used in:
ID is the unique identifier of the upload resource.
Total file size in bytes specified in the NewUpload call
Indicates whether the total file size is deferred until later
Offset in bytes (zero-based)
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.
Indicates that this is a final upload
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.
Storage contains information about where the data storage saves the upload, for example a file path. The available values vary depending on what data store is used. This map may also be nil.
FileInfoChanges collects changes the should be made to a FileInfo object. This can be done using the PreUploadCreateCallback to modify certain properties before an upload is created. Properties which should not be modified (e.g. Size or Offset) are intentionally left out here.
Used in:
If ID is not empty, it will be passed to the data store, allowing hooks to influence the upload ID. Be aware that a data store is not required to respect a pre-defined upload ID and might overwrite or modify it. However, all data stores in the github.com/tus/tusd package do respect pre-defined IDs.
If MetaData is not nil, it replaces the entire user-defined meta data from the upload creation request. You can add custom meta data fields this way or ensure that only certain fields from the user-defined meta data are saved. If you want to retain only specific entries from the user-defined meta data, you must manually copy them into this MetaData field. If you do not want to store any meta data, set this field to an empty map (`MetaData{}`). If you want to keep the entire user-defined meta data, set this field to nil.
If Storage is not nil, it is passed to the data store to allow for minor adjustments to the upload storage (e.g. destination file name). The details are specific for each data store and should be looked up in their respective documentation. Please be aware that this behavior is currently not supported by any data store in the github.com/tus/tusd package.
HTTPRequest contains basic details of an incoming HTTP request.
Used in:
Method is the HTTP method, e.g. POST or PATCH.
URI is the full HTTP request URI, e.g. /files/fooo.
RemoteAddr contains the network address that sent the request.
Header contains all HTTP headers as present in the HTTP request.
HTTPResponse contains basic details of an outgoing HTTP response.
Used in:
StatusCode is status code, e.g. 200 or 400.
Header contains additional HTTP headers for the response.
Body is the response body.