Skip to content

Commit 477a45f

Browse files
committed
Feat(file): add support of the chunked file upload (improvements)
Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>
1 parent efd8427 commit 477a45f

3 files changed

Lines changed: 311 additions & 72 deletions

File tree

‎openapi.json‎

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5006,11 +5006,11 @@
50065006
}
50075007
}
50085008
},
5009-
"/ocs/v2.php/apps/forms/api/v3/forms/{formId}/submissions/files/{questionId}/register": {
5009+
"/ocs/v2.php/apps/forms/api/v3/forms/{formId}/submissions/files/{questionId}/share": {
50105010
"post": {
5011-
"operationId": "api-register-uploaded-file",
5012-
"summary": "Register a file that was uploaded to an upload share",
5013-
"description": "This endpoint allows CORS requests",
5011+
"operationId": "api-create-upload-share",
5012+
"summary": "Create a temporary upload share for a file question",
5013+
"description": "Creates a temporary folder inside the form owner's storage and shares it via a create-only (file drop) public link. This allows uploading files over WebDAV - including chunked uploads - before the form is submitted. Uploaded files have to be registered using the `register` endpoint.\nThis endpoint allows CORS requests",
50145014
"tags": [
50155015
"api"
50165016
],
@@ -5021,30 +5021,18 @@
50215021
}
50225022
],
50235023
"requestBody": {
5024-
"required": true,
5024+
"required": false,
50255025
"content": {
50265026
"application/json": {
50275027
"schema": {
50285028
"type": "object",
50295029
"properties": {
5030-
"shareToken": {
5031-
"type": "string",
5032-
"description": "token of the upload share (see `share` endpoint)"
5033-
},
5034-
"fileName": {
5035-
"type": "string",
5036-
"description": "name of the uploaded file inside the share"
5037-
},
50385030
"shareHash": {
50395031
"type": "string",
50405032
"default": "",
50415033
"description": "hash of the form share"
50425034
}
5043-
},
5044-
"required": [
5045-
"shareToken",
5046-
"fileName"
5047-
]
5035+
}
50485036
}
50495037
}
50505038
}
@@ -5083,7 +5071,7 @@
50835071
],
50845072
"responses": {
50855073
"200": {
5086-
"description": "the file id and name of the registered file",
5074+
"description": "the token of the created upload share",
50875075
"content": {
50885076
"application/json": {
50895077
"schema": {
@@ -5103,7 +5091,7 @@
51035091
"$ref": "#/components/schemas/OCSMeta"
51045092
},
51055093
"data": {
5106-
"$ref": "#/components/schemas/UploadedFile"
5094+
"$ref": "#/components/schemas/UploadShare"
51075095
}
51085096
}
51095097
}
@@ -5113,7 +5101,7 @@
51135101
}
51145102
},
51155103
"400": {
5116-
"description": "File type is not allowed",
5104+
"description": "Could not create the upload share",
51175105
"content": {
51185106
"application/json": {
51195107
"schema": {
@@ -5169,7 +5157,7 @@
51695157
}
51705158
},
51715159
"404": {
5172-
"description": "Could not find question or uploaded file",
5160+
"description": "Could not find question",
51735161
"content": {
51745162
"application/json": {
51755163
"schema": {
@@ -5199,11 +5187,11 @@
51995187
}
52005188
}
52015189
},
5202-
"/ocs/v2.php/apps/forms/api/v3/forms/{formId}/submissions/files/{questionId}/share": {
5190+
"/ocs/v2.php/apps/forms/api/v3/forms/{formId}/submissions/files/{questionId}/register": {
52035191
"post": {
5204-
"operationId": "api-create-upload-share",
5205-
"summary": "Create a temporary upload share for a file question",
5206-
"description": "This endpoint allows CORS requests",
5192+
"operationId": "api-register-uploaded-file",
5193+
"summary": "Register a file that was uploaded to an upload share",
5194+
"description": "Looks up the file inside the folder of the given upload share, validates it against the question settings and binds it to the form and question. The returned `uploadedFileId` and `uploadToken` can then be used as an answer when submitting the form.\nThis endpoint allows CORS requests",
52075195
"tags": [
52085196
"api"
52095197
],
@@ -5214,12 +5202,24 @@
52145202
}
52155203
],
52165204
"requestBody": {
5217-
"required": false,
5205+
"required": true,
52185206
"content": {
52195207
"application/json": {
52205208
"schema": {
52215209
"type": "object",
5210+
"required": [
5211+
"shareToken",
5212+
"fileName"
5213+
],
52225214
"properties": {
5215+
"shareToken": {
5216+
"type": "string",
5217+
"description": "token of the upload share (see `share` endpoint)"
5218+
},
5219+
"fileName": {
5220+
"type": "string",
5221+
"description": "name of the uploaded file inside the share"
5222+
},
52235223
"shareHash": {
52245224
"type": "string",
52255225
"default": "",
@@ -5264,7 +5264,7 @@
52645264
],
52655265
"responses": {
52665266
"200": {
5267-
"description": "the token of the created upload share",
5267+
"description": "the file id and name of the registered file",
52685268
"content": {
52695269
"application/json": {
52705270
"schema": {
@@ -5284,7 +5284,7 @@
52845284
"$ref": "#/components/schemas/OCSMeta"
52855285
},
52865286
"data": {
5287-
"$ref": "#/components/schemas/UploadShare"
5287+
"$ref": "#/components/schemas/UploadedFile"
52885288
}
52895289
}
52905290
}
@@ -5294,7 +5294,7 @@
52945294
}
52955295
},
52965296
"400": {
5297-
"description": "Could not create the upload share",
5297+
"description": "File type is not allowed",
52985298
"content": {
52995299
"application/json": {
53005300
"schema": {
@@ -5350,7 +5350,7 @@
53505350
}
53515351
},
53525352
"404": {
5353-
"description": "Could not find question",
5353+
"description": "Could not find question or uploaded file",
53545354
"content": {
53555355
"application/json": {
53565356
"schema": {

0 commit comments

Comments
 (0)