mirror of
https://github.com/Forceu/Gokapi.git
synced 2025-12-30 13:29:34 -06:00
639 lines
18 KiB
JSON
639 lines
18 KiB
JSON
{
|
|
"openapi": "3.0.0",
|
|
"info": {
|
|
"title": "Gokapi",
|
|
"description": "[https://github.com/Forceu/Gokapi](https://github.com/Forceu/Gokapi)\n",
|
|
"version": "1.0"
|
|
},
|
|
"servers": [
|
|
{
|
|
"url": "/api/",
|
|
"description": "Target Server"
|
|
}
|
|
],
|
|
"security": [
|
|
{
|
|
"apikey": ["VIEW","UPLOAD","DELETE", "API_MANAGE"]
|
|
},
|
|
{
|
|
"session": []
|
|
}
|
|
],
|
|
"tags": [
|
|
{
|
|
"name": "files"
|
|
},
|
|
{
|
|
"name": "auth"
|
|
}
|
|
],
|
|
"paths": {
|
|
"/files/list": {
|
|
"get": {
|
|
"tags": [
|
|
"files"
|
|
],
|
|
"summary": "Lists all files",
|
|
"description": "This API call lists all files that are not expired.",
|
|
"operationId": "list",
|
|
"security": [
|
|
{
|
|
"apikey": ["VIEW"]
|
|
},
|
|
{
|
|
"session": []
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Operation successful",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/File"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Invalid input"
|
|
},
|
|
"401": {
|
|
"description": "Invalid API key provided or not logged in as admin"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/chunk/add": {
|
|
"post": {
|
|
"tags": [
|
|
"files"
|
|
],
|
|
"summary": "Uploads a new chunk",
|
|
"description": "Uploads a file in chunks, in case a reverse proxy does not support upload of larger files. Parallel uploading is supported. Must call /chunk/complete after all chunks have been uploaded. WARNING: Does not support end-to-end encryption! If server is setup to utilise end-to-end encryption, file will be stored in plain-text!",
|
|
"operationId": "chunkadd",
|
|
"security": [
|
|
{
|
|
"apikey": ["UPLOAD"]
|
|
},
|
|
{
|
|
"session": []
|
|
}
|
|
],
|
|
"requestBody": {
|
|
"content": {
|
|
"multipart/form-data": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/chunking"
|
|
}
|
|
}
|
|
},
|
|
"required": true
|
|
},
|
|
"responses": {
|
|
"200": {
|
|
"description": "Operation successful",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/chunkUploadResult"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Invalid input"
|
|
},
|
|
"401": {
|
|
"description": "Invalid API key provided or not logged in as admin"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/chunk/complete": {
|
|
"post": {
|
|
"tags": [
|
|
"files"
|
|
],
|
|
"summary": "Finalises uploaded chunks",
|
|
"description": "Needs to be called after all chunks have been uploaded. Adds the uploaded file to Gokapi.",
|
|
"operationId": "chunkcomplete",
|
|
"security": [
|
|
{
|
|
"apikey": ["UPLOAD"]
|
|
},
|
|
{
|
|
"session": []
|
|
}
|
|
],
|
|
"requestBody": {
|
|
"content": {
|
|
"application/x-www-form-urlencoded": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/chunkingcomplete"
|
|
}
|
|
}
|
|
},
|
|
"required": true
|
|
},
|
|
"responses": {
|
|
"200": {
|
|
"description": "Operation successful",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/UploadResult"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Invalid input"
|
|
},
|
|
"401": {
|
|
"description": "Invalid API key provided or not logged in as admin"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/files/add": {
|
|
"post": {
|
|
"tags": [
|
|
"files"
|
|
],
|
|
"summary": "Adds a new file without chunking",
|
|
"description": "Uploads the submitted file to Gokapi. Please note: This method does not use chunking, therefore if you are behind a reverse proxy or have a provider that limits upload filesizes, this might not work for bigger files (e.g. Cloudflare). WARNING: Does not support end-to-end encryption! If server is setup to utilise end-to-end encryption, file will be stored in plain-text!",
|
|
"operationId": "add",
|
|
"security": [
|
|
{
|
|
"apikey": ["UPLOAD"]
|
|
},
|
|
{
|
|
"session": []
|
|
}
|
|
],
|
|
"requestBody": {
|
|
"content": {
|
|
"multipart/form-data": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/body"
|
|
}
|
|
}
|
|
},
|
|
"required": true
|
|
},
|
|
"responses": {
|
|
"200": {
|
|
"description": "Operation successful",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/UploadResult"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Invalid input"
|
|
},
|
|
"401": {
|
|
"description": "Invalid API key provided or not logged in as admin"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/files/duplicate": {
|
|
"post": {
|
|
"tags": [
|
|
"files"
|
|
],
|
|
"summary": "Duplicates an existing file",
|
|
"description": "This API call duplicates an existing file with new parameters",
|
|
"operationId": "duplicate",
|
|
"security": [
|
|
{
|
|
"apikey": ["VIEW","UPLOAD"]
|
|
},
|
|
{
|
|
"session": []
|
|
}
|
|
],
|
|
"requestBody": {
|
|
"content": {
|
|
"application/x-www-form-urlencoded": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/duplicate"
|
|
}
|
|
}
|
|
},
|
|
"required": true
|
|
},
|
|
"responses": {
|
|
"200": {
|
|
"description": "Operation successful",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/UploadResult"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Invalid input"
|
|
},
|
|
"401": {
|
|
"description": "Invalid API key provided or not logged in as admin"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/files/delete": {
|
|
"delete": {
|
|
"tags": [
|
|
"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",
|
|
"operationId": "delete",
|
|
"security": [
|
|
{
|
|
"apikey": ["DELETE"]
|
|
},
|
|
{
|
|
"session": []
|
|
}
|
|
],
|
|
"parameters": [
|
|
{
|
|
"name": "id",
|
|
"in": "header",
|
|
"description": "The ID of the file to be deleted",
|
|
"required": true,
|
|
"style": "simple",
|
|
"explode": false,
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Operation successful"
|
|
},
|
|
"400": {
|
|
"description": "Invalid ID supplied"
|
|
},
|
|
"401": {
|
|
"description": "Invalid API key provided or not logged in as admin"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/auth/friendlyname": {
|
|
"put": {
|
|
"tags": [
|
|
"auth"
|
|
],
|
|
"summary": "Changes the name of the API key",
|
|
"description": "This API call changes the name of the API key that is shown in the API overview",
|
|
"operationId": "friendlyname",
|
|
"security": [
|
|
{
|
|
"apikey": ["API_MANAGE"]
|
|
},
|
|
{
|
|
"session": []
|
|
}
|
|
],
|
|
"parameters": [
|
|
{
|
|
"name": "apiKeyToModify",
|
|
"in": "header",
|
|
"description": "The API key to change the name of",
|
|
"required": true,
|
|
"style": "simple",
|
|
"explode": false,
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
{
|
|
"name": "friendlyName",
|
|
"in": "header",
|
|
"description": "The new name of a API key",
|
|
"required": true,
|
|
"style": "simple",
|
|
"explode": false,
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Operation successful"
|
|
},
|
|
"400": {
|
|
"description": "Invalid ID supplied"
|
|
},
|
|
"401": {
|
|
"description": "Invalid API key provided or not logged in as admin"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/auth/modifypermission": {
|
|
"put": {
|
|
"tags": [
|
|
"auth"
|
|
],
|
|
"summary": "Changes the permissions of the API key",
|
|
"description": "This API call changes the permissions for the given API key",
|
|
"operationId": "modifypermission",
|
|
"security": [
|
|
{
|
|
"apikey": ["API_MANAGE"]
|
|
},
|
|
{
|
|
"session": []
|
|
}
|
|
],
|
|
"parameters": [
|
|
{
|
|
"name": "apiKeyToModify",
|
|
"in": "header",
|
|
"description": "The API key to change the permission of",
|
|
"required": true,
|
|
"style": "simple",
|
|
"explode": false,
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
{
|
|
"name": "permission",
|
|
"in": "header",
|
|
"description": "The name of the permission",
|
|
"required": true,
|
|
"style": "simple",
|
|
"explode": false,
|
|
"schema": {
|
|
"type": "string",
|
|
"enum": ["PERM_VIEW", "PERM_UPLOAD", "PERM_DELETE", "PERM_API_MOD"]
|
|
}
|
|
},
|
|
{
|
|
"name": "permissionModifier",
|
|
"in": "header",
|
|
"description": "If the permission shall be granted or revoked",
|
|
"required": true,
|
|
"style": "simple",
|
|
"explode": false,
|
|
"schema": {
|
|
"type": "string",
|
|
"enum": ["GRANT", "REVOKE"]
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Operation successful"
|
|
},
|
|
"400": {
|
|
"description": "Invalid ID supplied"
|
|
},
|
|
"401": {
|
|
"description": "Invalid API key provided or not logged in as admin"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"components": {
|
|
"schemas": {
|
|
"File": {
|
|
"type": "object",
|
|
"properties": {
|
|
"Id": {
|
|
"type": "string"
|
|
},
|
|
"Name": {
|
|
"type": "string"
|
|
},
|
|
"Size": {
|
|
"type": "string"
|
|
},
|
|
"SizeBytes": {
|
|
"type": "integer",
|
|
"format": "int64"
|
|
},
|
|
"HotlinkId": {
|
|
"type": "string"
|
|
},
|
|
"ContentType": {
|
|
"type": "string"
|
|
},
|
|
"ExpireAt": {
|
|
"type": "integer",
|
|
"format": "int64"
|
|
},
|
|
"ExpireAtString": {
|
|
"type": "string"
|
|
},
|
|
"DownloadsRemaining": {
|
|
"type": "integer",
|
|
"format": "int64"
|
|
},
|
|
"DownloadCount": {
|
|
"type": "integer",
|
|
"format": "int64"
|
|
},
|
|
"UnlimitedDownloads": {
|
|
"type": "boolean"
|
|
},
|
|
"UnlimitedTime": {
|
|
"type": "boolean"
|
|
},
|
|
"RequiresClientSideDecryption": {
|
|
"type": "boolean"
|
|
},
|
|
"IsEncrypted": {
|
|
"type": "boolean"
|
|
},
|
|
"IsPasswordProtected": {
|
|
"type": "boolean"
|
|
},
|
|
"IsSavedOnLocalStorage": {
|
|
"type": "boolean"
|
|
}
|
|
},
|
|
"description": "File is a struct used for saving information about an uploaded file",
|
|
"x-go-package": "Gokapi/internal/models"
|
|
},
|
|
"chunkUploadResult": {
|
|
"type": "object",
|
|
"properties": {
|
|
"Result": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"description": "Result after uploading a chunk",
|
|
"x-go-package": "Gokapi/internal/models"
|
|
},
|
|
"UploadResult": {
|
|
"type": "object",
|
|
"properties": {
|
|
"Result": {
|
|
"type": "string"
|
|
},
|
|
"FileInfo": {
|
|
"$ref": "#/components/schemas/File"
|
|
},
|
|
"HotlinkUrl": {
|
|
"type": "string"
|
|
},
|
|
"Url": {
|
|
"type": "string"
|
|
},
|
|
"GenericHotlinkUrl": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"description": "UploadResult is the struct used for the result after an upload",
|
|
"x-go-package": "Gokapi/internal/models"
|
|
},
|
|
"body": {
|
|
"required": [
|
|
"file"
|
|
],
|
|
"type": "object",
|
|
"properties": {
|
|
"file": {
|
|
"type": "string",
|
|
"description": "The file to be uploaded",
|
|
"format": "binary"
|
|
},
|
|
"allowedDownloads": {
|
|
"type": "integer",
|
|
"description": "How many downloads are allowed. Last used value from web interface will be used if empty. Unlimited if 0 is passed."
|
|
},
|
|
"expiryDays": {
|
|
"type": "integer",
|
|
"description": "How many days the file will be stored. Last used value from web interface will be used if empty. Unlimited if 0 is passed."
|
|
},
|
|
"password": {
|
|
"type": "string",
|
|
"description": "Password for this file to be set. No password will be used if empty"
|
|
}
|
|
}
|
|
},"duplicate": {
|
|
"required": [
|
|
"id"
|
|
],
|
|
"type": "object",
|
|
"properties": {
|
|
"id": {
|
|
"type": "string",
|
|
"description": "ID of file to be duplicated"
|
|
},
|
|
"allowedDownloads": {
|
|
"type": "integer",
|
|
"description": "How many downloads are allowed. Original value from web interface will be used if empty. Unlimited if 0 is passed."
|
|
},
|
|
"expiryDays": {
|
|
"type": "integer",
|
|
"description": "How many days the file will be stored. Original value from web interface will be used if empty. Unlimited if 0 is passed."
|
|
},
|
|
"password": {
|
|
"type": "string",
|
|
"description": "Password for this file to be set. No password will be used if empty."
|
|
},
|
|
"originalPassword": {
|
|
"type": "boolean",
|
|
"description": "Set to true to use original password. Field \"password\" will be ignored if set."
|
|
},
|
|
"filename": {
|
|
"type": "string",
|
|
"description": "Sets a new filename. Filename will be unchanged if empty."
|
|
}
|
|
}
|
|
},"chunking": {
|
|
"required": [
|
|
"file","uuid","filesize","offset"
|
|
],
|
|
"type": "object",
|
|
"properties": {
|
|
"file": {
|
|
"type": "string",
|
|
"description": "The file to be uploaded",
|
|
"format": "binary"
|
|
},
|
|
"uuid": {
|
|
"type": "string",
|
|
"description": "A unique ID that has to be the same for all chunks of a single file. Needs to be at least 10 characters long."
|
|
},
|
|
"filesize": {
|
|
"type": "integer",
|
|
"description": "The total filesize of the final file in bytes"
|
|
},
|
|
"offset": {
|
|
"type": "integer",
|
|
"description": "The chunk's offset starting at the beginning of the file"
|
|
}
|
|
}
|
|
},"chunkingcomplete": {
|
|
"required": [
|
|
"uuid","filename","filesize"
|
|
],
|
|
"type": "object",
|
|
"properties": {
|
|
"uuid": {
|
|
"type": "string",
|
|
"description": "The unique ID that was used for the uploaded chunks"
|
|
},
|
|
"filename": {
|
|
"type": "string",
|
|
"description": "The filename of the uploaded file"
|
|
},
|
|
"filesize": {
|
|
"type": "integer",
|
|
"description": "The total filesize of the uploaded file in bytes"
|
|
},
|
|
"contenttype": {
|
|
"type": "string",
|
|
"description": "The MIME content type. If empty, application/octet-stream will be used."
|
|
},
|
|
"allowedDownloads": {
|
|
"type": "integer",
|
|
"description": "How many downloads are allowed. Last used value from web interface will be used if empty. Unlimited if 0 is passed."
|
|
},
|
|
"expiryDays": {
|
|
"type": "integer",
|
|
"description": "How many days the file will be stored. Last used value from web interface will be used if empty. Unlimited if 0 is passed."
|
|
},
|
|
"password": {
|
|
"type": "string",
|
|
"description": "Password for this file to be set. No password will be used if empty"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"securitySchemes": {
|
|
"apikey": {
|
|
"type": "apiKey",
|
|
"name": "apikey",
|
|
"in": "header"
|
|
},
|
|
"session": {
|
|
"type": "apiKey",
|
|
"name": "session_token",
|
|
"in": "cookie"
|
|
}
|
|
}
|
|
}
|
|
}
|