mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: add api docs (#1965)
This commit is contained in:
130
docs/api/resource.md
Normal file
130
docs/api/resource.md
Normal file
@@ -0,0 +1,130 @@
|
||||
# Resource APIs
|
||||
|
||||
## Upload Resource
|
||||
|
||||
### Upload File
|
||||
|
||||
```
|
||||
POST /api/v1/resource/blob
|
||||
```
|
||||
|
||||
**Request Form**
|
||||
|
||||
- `file`: Upload file
|
||||
|
||||
**Response**
|
||||
|
||||
```json
|
||||
{
|
||||
"id": 123,
|
||||
"filename": "example.png"
|
||||
// other fields
|
||||
}
|
||||
```
|
||||
|
||||
**Status Codes**
|
||||
|
||||
- 200: OK
|
||||
- 400: Invalid request
|
||||
- 401: Unauthorized
|
||||
- 413: File too large
|
||||
- 500: Internal server error
|
||||
|
||||
### Create Resource
|
||||
|
||||
```
|
||||
POST /api/v1/resource
|
||||
```
|
||||
|
||||
**Request Body**
|
||||
|
||||
```json
|
||||
{
|
||||
"filename": "example.png",
|
||||
"externalLink": "https://example.com/image.png"
|
||||
}
|
||||
```
|
||||
|
||||
**Response**
|
||||
|
||||
Same as **Upload File**
|
||||
|
||||
**Status Codes**
|
||||
|
||||
- 200: OK
|
||||
- 400: Invalid request
|
||||
- 401: Unauthorized
|
||||
- 500: Internal server error
|
||||
|
||||
## Get Resource List
|
||||
|
||||
```
|
||||
GET /api/v1/resource
|
||||
```
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `limit` (optional): Limit number of results
|
||||
- `offset` (optional): Offset of first result
|
||||
|
||||
**Response**
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"id": 123,
|
||||
"filename": "example.png"
|
||||
// other fields
|
||||
},
|
||||
{
|
||||
"id": 456,
|
||||
"filename": "doc.pdf"
|
||||
// other fields
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
**Status Codes**
|
||||
|
||||
- 200: OK
|
||||
- 401: Unauthorized
|
||||
- 500: Internal server error
|
||||
|
||||
## Update Resource
|
||||
|
||||
```
|
||||
PATCH /api/v1/resource/:resourceId
|
||||
```
|
||||
|
||||
**Request Body**
|
||||
|
||||
```json
|
||||
{
|
||||
"filename": "new_name.png"
|
||||
}
|
||||
```
|
||||
|
||||
**Response**
|
||||
|
||||
Same as **Get Resource List**
|
||||
|
||||
**Status Codes**
|
||||
|
||||
- 200: OK
|
||||
- 400: Invalid request
|
||||
- 401: Unauthorized
|
||||
- 404: Not found
|
||||
- 500: Internal server error
|
||||
|
||||
## Delete Resource
|
||||
|
||||
```
|
||||
DELETE /api/v1/resource/:resourceId
|
||||
```
|
||||
|
||||
**Status Codes**
|
||||
|
||||
- 200: Deleted
|
||||
- 401: Unauthorized
|
||||
- 404: Not found
|
||||
- 500: Internal server error
|
Reference in New Issue
Block a user