mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-02 05:02:29 +08:00
🎨 提供读写文件 API Fix https://github.com/siyuan-note/siyuan/issues/4343
This commit is contained in:
parent
561e722f6d
commit
fcf1ec4c91
43
API.md
43
API.md
@ -34,6 +34,9 @@
|
|||||||
* [Execute SQL query](#Execute-SQL-query)
|
* [Execute SQL query](#Execute-SQL-query)
|
||||||
* [Templates](#Templates)
|
* [Templates](#Templates)
|
||||||
* [Render a template](#Render-a-template)
|
* [Render a template](#Render-a-template)
|
||||||
|
* [File](#File)
|
||||||
|
* [Get File](#Get-file)
|
||||||
|
* [Put File](#Put-file)
|
||||||
* [Export](#Export)
|
* [Export](#Export)
|
||||||
* [Export Markdown](#Export-Markdown)
|
* [Export Markdown](#Export-Markdown)
|
||||||
* [System](#System)
|
* [System](#System)
|
||||||
@ -50,7 +53,8 @@
|
|||||||
|
|
||||||
* Endpoint: `http://127.0.0.1:6806`
|
* Endpoint: `http://127.0.0.1:6806`
|
||||||
* Both are POST methods
|
* Both are POST methods
|
||||||
* An interface with parameters is required, the parameter is a JSON string, placed in the body, and the header Content-Type is `application/json`
|
* An interface with parameters is required, the parameter is a JSON string, placed in the body, and the header
|
||||||
|
Content-Type is `application/json`
|
||||||
* Return value
|
* Return value
|
||||||
|
|
||||||
````json
|
````json
|
||||||
@ -61,9 +65,9 @@
|
|||||||
}
|
}
|
||||||
````
|
````
|
||||||
|
|
||||||
* `code`: non-zero for exceptions
|
* `code`: non-zero for exceptions
|
||||||
* `msg`: an empty string under normal circumstances, an error text will be returned under abnormal conditions
|
* `msg`: an empty string under normal circumstances, an error text will be returned under abnormal conditions
|
||||||
* `data`: may be `{}`, `[]` or `NULL`, depending on the interface
|
* `data`: may be `{}`, `[]` or `NULL`, depending on the interface
|
||||||
|
|
||||||
### Authentication
|
### Authentication
|
||||||
|
|
||||||
@ -305,7 +309,8 @@ View API token in <kbd>Settings - About</kbd>, request header: `Authorization: T
|
|||||||
```
|
```
|
||||||
|
|
||||||
* `notebook`: Notebook ID
|
* `notebook`: Notebook ID
|
||||||
* `path`: Document path, which needs to start with / and separate levels with / (path here corresponds to the database hpath field)
|
* `path`: Document path, which needs to start with / and separate levels with / (path here corresponds to the
|
||||||
|
database hpath field)
|
||||||
* `markdown`: GFM Markdown content
|
* `markdown`: GFM Markdown content
|
||||||
* Return value
|
* Return value
|
||||||
|
|
||||||
@ -318,7 +323,8 @@ View API token in <kbd>Settings - About</kbd>, request header: `Authorization: T
|
|||||||
```
|
```
|
||||||
|
|
||||||
* `data`: Created document ID
|
* `data`: Created document ID
|
||||||
* If you use the same `path` to call this interface repeatedly, the existing document will not be overwritten, but a new document ending with a random number will be created
|
* If you use the same `path` to call this interface repeatedly, the existing document will not be overwritten, but a
|
||||||
|
new document ending with a random number will be created
|
||||||
|
|
||||||
### Rename a document
|
### Rename a document
|
||||||
|
|
||||||
@ -432,7 +438,7 @@ View API token in <kbd>Settings - About</kbd>, request header: `Authorization: T
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
* `id`:Block ID
|
* `id`:Block ID
|
||||||
* Return value
|
* Return value
|
||||||
|
|
||||||
```json
|
```json
|
||||||
@ -474,7 +480,9 @@ View API token in <kbd>Settings - About</kbd>, request header: `Authorization: T
|
|||||||
```
|
```
|
||||||
|
|
||||||
* `errFiles`: List of filenames with errors in upload processing
|
* `errFiles`: List of filenames with errors in upload processing
|
||||||
* `succMap`: For successfully processed files, the key is the file name when uploading, and the value is assets/foo-id.png, which is used to replace the asset link address in the existing Markdown content with the uploaded address
|
* `succMap`: For successfully processed files, the key is the file name when uploading, and the value is
|
||||||
|
assets/foo-id.png, which is used to replace the asset link address in the existing Markdown content with the
|
||||||
|
uploaded address
|
||||||
|
|
||||||
## Blocks
|
## Blocks
|
||||||
|
|
||||||
@ -780,12 +788,11 @@ View API token in <kbd>Settings - About</kbd>, request header: `Authorization: T
|
|||||||
* `/api/file/getFile`
|
* `/api/file/getFile`
|
||||||
* Parameters
|
* Parameters
|
||||||
|
|
||||||
``json
|
``json {
|
||||||
{
|
"path": "/data/20210808180117-6v0mkxr/20200923234011-ieuun1p.sy"
|
||||||
"path": "/data/20210808180117-6v0mkxr/20200923234011-ieuun1p.sy"
|
}
|
||||||
}
|
``
|
||||||
``
|
* `path`: the file path under the workspace path
|
||||||
* `path`: the file path under the workspace path
|
|
||||||
* Return value
|
* Return value
|
||||||
|
|
||||||
File content
|
File content
|
||||||
@ -795,10 +802,10 @@ View API token in <kbd>Settings - About</kbd>, request header: `Authorization: T
|
|||||||
* `/api/file/putFile`
|
* `/api/file/putFile`
|
||||||
* The parameter is an HTTP Multipart form
|
* The parameter is an HTTP Multipart form
|
||||||
|
|
||||||
* `path`: the file path under the workspace path
|
* `path`: the file path under the workspace path
|
||||||
* `isDir`: whether to create a folder, when `true` only create a folder, ignore `file`
|
* `isDir`: whether to create a folder, when `true` only create a folder, ignore `file`
|
||||||
* `modTime`: last access and modification time, Unix time
|
* `modTime`: last access and modification time, Unix time
|
||||||
* `file`: the uploaded file
|
* `file`: the uploaded file
|
||||||
* return value
|
* return value
|
||||||
|
|
||||||
```json
|
```json
|
||||||
|
Loading…
Reference in New Issue
Block a user