1
1
// If this file gets changed, you must recompile the generate package in pkg/proto.
2
2
// To do this, install the Go protobuf toolchain as mentioned in
3
- // https://github.com/golang/protobuf#installation .
4
- // Then use following command to recompile it with gRPC support:
5
- // protoc --go_out=plugins=grpc:../../../../../pkg/ proto/ v2/hook.proto
3
+ // https://grpc.io/docs/languages/go/quickstart/#prerequisites .
4
+ // Then use following command from the repository's root to recompile it with gRPC support:
5
+ // protoc --go-grpc_out=./pkg/ --go_out=./pkg/ ./cmd/tusd/cli/hooks/ proto/v2/hook.proto
6
6
// In addition, it may be necessary to update the protobuf or gRPC dependencies as well.
7
7
8
8
syntax = "proto3" ;
9
9
package v2 ;
10
10
11
+ option go_package = "proto/v2" ;
12
+
11
13
// HookRequest contains the information about the hook type, the involved upload,
12
14
// and causing HTTP request.
13
15
message HookRequest {
@@ -56,6 +58,35 @@ message FileInfo {
56
58
map <string , string > storage = 9 ;
57
59
}
58
60
61
+ // FileInfoChanges collects changes the should be made to a FileInfo object. This
62
+ // can be done using the PreUploadCreateCallback to modify certain properties before
63
+ // an upload is created. Properties which should not be modified (e.g. Size or Offset)
64
+ // are intentionally left out here.
65
+ message FileInfoChanges {
66
+ // If ID is not empty, it will be passed to the data store, allowing
67
+ // hooks to influence the upload ID. Be aware that a data store is not required to
68
+ // respect a pre-defined upload ID and might overwrite or modify it. However,
69
+ // all data stores in the github.com/tus/tusd package do respect pre-defined IDs.
70
+ string id = 1 ;
71
+
72
+ // If MetaData is not nil, it replaces the entire user-defined meta data from
73
+ // the upload creation request. You can add custom meta data fields this way
74
+ // or ensure that only certain fields from the user-defined meta data are saved.
75
+ // If you want to retain only specific entries from the user-defined meta data, you must
76
+ // manually copy them into this MetaData field.
77
+ // If you do not want to store any meta data, set this field to an empty map (`MetaData{}`).
78
+ // If you want to keep the entire user-defined meta data, set this field to nil.
79
+ map <string , string > metaData = 2 ;
80
+
81
+ // If Storage is not nil, it is passed to the data store to allow for minor adjustments
82
+ // to the upload storage (e.g. destination file name). The details are specific for each
83
+ // data store and should be looked up in their respective documentation.
84
+ // Please be aware that this behavior is currently not supported by any data store in
85
+ // the github.com/tus/tusd package.
86
+ map <string , string > storage = 3 ;
87
+ }
88
+
89
+
59
90
// HTTPRequest contains basic details of an incoming HTTP request.
60
91
message HTTPRequest {
61
92
// Method is the HTTP method, e.g. POST or PATCH.
@@ -87,6 +118,13 @@ message HookResponse {
87
118
// to the client.
88
119
bool rejectUpload = 2 ;
89
120
121
+ // ChangeFileInfo can be set to change selected properties of an upload before
122
+ // it has been created. See the handler.FileInfoChanges type for more details.
123
+ // Changes are applied on a per-property basis, meaning that specifying just
124
+ // one property leaves all others unchanged.
125
+ // This value is only respected for pre-create hooks.
126
+ FileInfoChanges changeFileInfo = 4 ;
127
+
90
128
// StopUpload will cause the upload to be stopped during a PATCH request.
91
129
// This value is only respected for post-receive hooks. For other hooks,
92
130
// it is ignored. Use the HTTPResponse field to send details about the stop
@@ -104,7 +142,6 @@ message HTTPResponse {
104
142
string body = 3 ;
105
143
}
106
144
107
-
108
145
// The hook service definition.
109
146
service HookHandler {
110
147
// InvokeHook is invoked for every hook that is executed. HookRequest contains the
0 commit comments