2023-10-07 15:51:18 +02:00
|
|
|
openapi: 3.0.3
|
|
|
|
info:
|
|
|
|
title: blek! File (fileD) File API
|
|
|
|
description: |-
|
|
|
|
This document describes the API of the File API of blek! File fileD.
|
|
|
|
|
|
|
|
This API has optional api key authorization, which should be located in the env file.
|
|
|
|
version: 0.0.1
|
|
|
|
servers:
|
|
|
|
- url: http://localhost
|
|
|
|
description: Local staging environment
|
2023-10-08 07:01:48 +02:00
|
|
|
tags:
|
|
|
|
- name: File API
|
|
|
|
description: API for interacting with files
|
2023-10-07 15:51:18 +02:00
|
|
|
paths:
|
2023-10-08 07:01:48 +02:00
|
|
|
/api/files/get_all:
|
2023-10-07 15:51:18 +02:00
|
|
|
get:
|
|
|
|
summary: Get all files
|
|
|
|
description: |-
|
|
|
|
Get all files available.
|
|
|
|
|
2023-10-08 07:01:48 +02:00
|
|
|
Returns an array of file objects with all data
|
|
|
|
tags:
|
|
|
|
- File API
|
2023-10-07 15:51:18 +02:00
|
|
|
security:
|
|
|
|
- apikey: [ key ]
|
|
|
|
responses:
|
|
|
|
200:
|
2023-10-08 07:01:48 +02:00
|
|
|
description: An array of file objects
|
2023-10-07 15:51:18 +02:00
|
|
|
content:
|
|
|
|
application/json:
|
|
|
|
schema:
|
|
|
|
type: array
|
|
|
|
items:
|
2023-10-08 07:01:48 +02:00
|
|
|
$ref: '#/components/schemas/File'
|
|
|
|
example:
|
|
|
|
- path: /opt/useruploads/417e1ec1a0e82aac809da7e5aa309e03bf47eaa96ab2e335f5bb739d062d835b04ccebb89214bd5a54879527789a81ae4e9deab813e4212c757b36d08fa8165a
|
|
|
|
size: 10
|
|
|
|
name: null
|
|
|
|
mime: text/plain
|
|
|
|
delete_at: '1984-01-01T00:00:00.000Z'
|
|
|
|
sha512: 417e1ec1a0e82aac809da7e5aa309e03bf47eaa96ab2e335f5bb739d062d835b04ccebb89214bd5a54879527789a81ae4e9deab813e4212c757b36d08fa8165a
|
2023-10-08 07:15:41 +02:00
|
|
|
401:
|
|
|
|
description: |-
|
|
|
|
This error code is returned if one of the two conditions are met:
|
|
|
|
|
|
|
|
1. The instance does not allow getting information about all files.
|
|
|
|
2. The instance requires API key for all API manipulations.
|
|
|
|
3. The provided API key is invalid.
|
|
|
|
4. API authorization is not enabled, but a key is provided
|
2023-10-08 07:01:48 +02:00
|
|
|
/api/files/delete:
|
2023-10-07 15:51:18 +02:00
|
|
|
post:
|
|
|
|
summary: Delete a file
|
|
|
|
description: |-
|
|
|
|
Deletes a file thats been uploaded.
|
|
|
|
|
|
|
|
It will work if one of the two conditions are met:
|
|
|
|
1. The requester's IP is the same as the uploader IP
|
|
|
|
2. The request is authorized with an API key
|
2023-10-08 07:01:48 +02:00
|
|
|
tags:
|
|
|
|
- File API
|
2023-10-07 15:51:18 +02:00
|
|
|
security:
|
|
|
|
- apikey: [ key ]
|
|
|
|
responses:
|
|
|
|
200:
|
|
|
|
description: |-
|
|
|
|
The file has been deleted
|
|
|
|
|
|
|
|
Returns an empty object for future extension
|
|
|
|
content:
|
|
|
|
application/json:
|
|
|
|
schema:
|
|
|
|
type: object
|
|
|
|
example: {}
|
2023-10-08 07:15:41 +02:00
|
|
|
401:
|
|
|
|
description: |-
|
|
|
|
This error code is returned if one of the two conditions are met:
|
|
|
|
|
|
|
|
1. The instance does not allow deleting files via API.
|
|
|
|
2. The file has been uploaded from another IP, which is not this one, and the API was not authorized via an API key.
|
|
|
|
3. The instance requires API key for all API manipulations.
|
|
|
|
4. The provided API key is invalid.
|
|
|
|
5. API authorization is not enabled, but a key is provided
|
|
|
|
requestBody:
|
|
|
|
content:
|
|
|
|
application/json:
|
|
|
|
schema:
|
|
|
|
type: object
|
|
|
|
properties:
|
|
|
|
fid:
|
|
|
|
type: string
|
|
|
|
example: ID or name of the file. It is the NAME in file.blek.codes/uploads/NAME
|
2023-10-08 07:07:15 +02:00
|
|
|
/api/files/upload:
|
|
|
|
post:
|
|
|
|
summary: Upload a file
|
|
|
|
description: |-
|
|
|
|
A programmatic way to upload a file.
|
|
|
|
|
|
|
|
The request must be encoded in `multipart/form-data` to ensure that the binary file is transferred properly.
|
|
|
|
tags:
|
|
|
|
- File API
|
2023-10-08 07:15:41 +02:00
|
|
|
security:
|
|
|
|
- apikey: [ key ]
|
2023-10-08 07:07:15 +02:00
|
|
|
requestBody:
|
|
|
|
content:
|
|
|
|
multipart/form-data:
|
|
|
|
schema:
|
|
|
|
type: object
|
|
|
|
properties:
|
|
|
|
file:
|
|
|
|
type: string
|
|
|
|
example: binary file data
|
|
|
|
description: binary file data
|
2023-10-26 17:17:03 +02:00
|
|
|
instance_pass:
|
|
|
|
type: string
|
|
|
|
example: super_secret_pass
|
|
|
|
description: Instance-specific password needed to upload files
|
2023-10-08 07:07:15 +02:00
|
|
|
metadata:
|
|
|
|
type: object
|
|
|
|
description: file info
|
|
|
|
properties:
|
|
|
|
sha512:
|
|
|
|
type: string
|
|
|
|
description: SHA512 hash of the file to ensure integrity
|
|
|
|
name:
|
|
|
|
type: string
|
|
|
|
description: Optional name of the file so it would be accessible like file.blek.codes/uploads/{name}
|
2023-12-11 00:58:49 +01:00
|
|
|
pass:
|
|
|
|
type: string
|
|
|
|
description: Optional password protection for the file
|
2023-10-08 07:07:15 +02:00
|
|
|
responses:
|
|
|
|
200:
|
|
|
|
description: File uploaded successfully
|
2023-10-08 07:15:41 +02:00
|
|
|
401:
|
|
|
|
description: |-
|
|
|
|
This error code is returned if one of the two conditions are met:
|
|
|
|
|
|
|
|
1. The instance does not allow API file uploads.
|
|
|
|
2. The instance requires API key for all API manipulations.
|
|
|
|
3. The provided API key is invalid.
|
|
|
|
4. API authorization is not enabled, but a key is provided
|
2023-10-07 15:51:18 +02:00
|
|
|
|
|
|
|
components:
|
|
|
|
|
|
|
|
schemas:
|
|
|
|
File:
|
|
|
|
type: object
|
|
|
|
properties:
|
|
|
|
path:
|
|
|
|
type: string
|
|
|
|
description: Path to the file in fileD's filesystem
|
|
|
|
example: 1
|
|
|
|
size:
|
|
|
|
type: integer
|
|
|
|
description: Size of the file in bytes
|
|
|
|
example: 10
|
|
|
|
name:
|
|
|
|
type: string
|
|
|
|
description: (optional) Name of the file
|
|
|
|
example: null
|
|
|
|
mime:
|
|
|
|
type: string
|
|
|
|
description: MIME type of the file
|
|
|
|
example: text/plain
|
|
|
|
delete_at:
|
|
|
|
type: string
|
|
|
|
description: TimeDate when the file will be deleted
|
|
|
|
example: '1984-01-01T00:00:00.000Z'
|
|
|
|
sha512:
|
|
|
|
type: string
|
|
|
|
example: 417e1ec1a0e82aac809da7e5aa309e03bf47eaa96ab2e335f5bb739d062d835b04ccebb89214bd5a54879527789a81ae4e9deab813e4212c757b36d08fa8165a
|
|
|
|
|
|
|
|
securitySchemes:
|
|
|
|
apikey:
|
|
|
|
type: http
|
|
|
|
scheme: bearer
|
|
|
|
description: Optional authorization, as defined in the instance-specific config file
|