mirror of
https://github.com/Forceu/Gokapi.git
synced 2026-05-03 04:51:15 -05:00
Add restore feature when deleting file from admin menu or API (#261)
* Added API call /files/restore, added parameter to /files/delete to add delay, have 10s delay when deleting from UI * Fixed DB upgrade function not exiting on old version, added and fixed tests
This commit is contained in:
+64
-3
@@ -484,7 +484,7 @@
|
||||
"files"
|
||||
],
|
||||
"summary": "Deletes the selected file",
|
||||
"description": "This API call deletes the selected file and runs the clean-up procedure which purges all expired files from the data directory immediately. Requires API permission DELETE. To delete a file that was not uploaded by the user, the user needs to have the user permission DELETE",
|
||||
"description": "This API call deletes the selected file and runs the clean-up procedure which purges all expired files from the data directory. Deletetion can be postponed with the parameter delay to be able to cancel deletion with the call /files/restore. Requires API permission DELETE. To delete a file that was not uploaded by the user, the user needs to have the user permission DELETE",
|
||||
"operationId": "delete",
|
||||
"security": [
|
||||
{
|
||||
@@ -497,11 +497,18 @@
|
||||
"in": "header",
|
||||
"description": "The ID of the file to be deleted",
|
||||
"required": true,
|
||||
"style": "simple",
|
||||
"explode": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "delay",
|
||||
"in": "header",
|
||||
"description": "The number of seconds to wait before deleting the file, in order to be able to restore it with /files/restore",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
@@ -517,6 +524,50 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/files/restore": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"files"
|
||||
],
|
||||
"summary": "Restores a file that is pending to be deleted",
|
||||
"description": "This API call cancels a pending deletion of the selected file that originally deleted with /files/delete. The call to restore has to be within the timeframe specified in the delay parameter of /files/delete. Requires API permission DELETE. To delete a file that was not uploaded by the user, the user needs to have the user permission DELETE",
|
||||
"operationId": "restore",
|
||||
"security": [
|
||||
{
|
||||
"apikey": ["DELETE"]
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "header",
|
||||
"description": "The ID of the file to be restored",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Operation successful",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/UploadResult"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Invalid API key provided for authentication or API key does not have the required permission"
|
||||
},
|
||||
"404": {
|
||||
"description": "Invalid ID supplied or the file has already been deleted"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/auth/create": {
|
||||
"post": {
|
||||
"tags": [
|
||||
@@ -1111,6 +1162,16 @@
|
||||
"description": "True if the file does not use cloud storage",
|
||||
"type": "boolean",
|
||||
"example": "true"
|
||||
},
|
||||
"IsPendingDeletion": {
|
||||
"description": "True if the file is about to be deleted",
|
||||
"type": "boolean",
|
||||
"example": "false"
|
||||
},
|
||||
"UploaderId": {
|
||||
"description": "The user ID of the uploader",
|
||||
"type": "integer",
|
||||
"example": "3"
|
||||
}
|
||||
},
|
||||
"description": "File is a struct used for saving information about an uploaded file",
|
||||
|
||||
Reference in New Issue
Block a user