/api/file
getFile
- 🔥 获取文件
/api/file/getFile
请求
ts
/**
* get file under the workspace directory
*/
export interface IPayload {
/**
* the file path under the workspace path
*/
readonly path: string;
}
json5
/**
* schemas/kernel/api/file/getFile/payload.schema.json5
* 获取文件
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#get-file
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/file.go#L83-L133
* @pathname: /api/file/getFile
* @version: 2.9.3
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/file/getFile/payload.schema.json5',
$comment: 'v2.9.3',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'payload body',
description: 'get file under the workspace directory',
type: 'object',
additionalProperties: false,
required: [
'path',
],
properties: {
path: {
// 工作空间路径下的文件路径
type: 'string',
description: 'the file path under the workspace path',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/file/getFile/payload.schema.json",
"$comment": "v2.9.3",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "payload body",
"description": "get file under the workspace directory",
"type": "object",
"additionalProperties": false,
"required": [
"path"
],
"properties": {
"path": {
"type": "string",
"description": "the file path under the workspace path"
}
}
}
}
}
putFile
- 🔥 写入文件
/api/file/putFile
请求
ts
/**
* Copyright (C) 2023 SiYuan Community
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see {@link http://www.gnu.org/licenses/}.
*/
/**
* put file under the workspace directory
*/
export type IPayload = IDirectory | IFile;
export interface IDirectory {
/**
* the file path under the workspace path
*/
path: string;
/**
* whether to create a folder, when true only create a folder, ignore file
*/
isDir: true;
/**
* the uploaded file
*/
file?: BlobPart | File;
/**
* last access and modification time, Unix time (ms)
*/
modTime?: number;
}
export interface IFile {
/**
* the file path under the workspace path
*/
path: string;
/**
* the uploaded file
*/
file: BlobPart | File;
/**
* whether to create a folder, when true only create a folder, ignore file
*/
isDir?: false;
/**
* last access and modification time, Unix time (ms)
*/
modTime?: number;
}
响应
ts
/**
* put file under the workspace directory
*/
export interface IResponse {
/**
* status code
*/
readonly code: number;
readonly data: null;
/**
* status message
*/
readonly msg: string;
}
json5
/**
* schemas/siyuan/api/file/putFile/response.schema.json5
* 获取思源内核版本号
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#put-file
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/file.go#L251-L328
* @pathname: /api/file/putFile
* @version: 2.9.3
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/file/putFile/response.schema.json5',
$comment: 'v2.9.3',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'response body',
description: 'put file under the workspace directory',
type: 'object',
additionalProperties: false,
required: [
'code',
'msg',
'data',
],
properties: {
code: {
type: 'integer',
description: 'status code',
},
msg: {
type: 'string',
description: 'status message',
},
data: {
type: 'null',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/file/putFile/response.schema.json",
"$comment": "v2.9.3",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "response body",
"description": "put file under the workspace directory",
"type": "object",
"additionalProperties": false,
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "status code"
},
"msg": {
"type": "string",
"description": "status message"
},
"data": {
"type": "null"
}
}
}
}
}
readDir
- 🔥 获取文件目录下级内容
/api/file/readDir
请求
ts
/**
* list the contents of the specified file directory
*/
export interface IPayload {
/**
* file/directory path relative to the SiYuan workspace directory
*/
readonly path: string;
}
json5
/**
* schemas/kernel/api/file/readDir/payload.schema.json5
* 列出指定文件目录下的内容
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#list-files
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.2/kernel/api/file.go#L135-L182
* @pathname: /api/file/readDir
* @version: 2.9.2
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/file/readDir/payload.schema.json5',
$comment: 'v2.9.2',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'payload body',
description: 'list the contents of the specified file directory',
type: 'object',
additionalProperties: false,
required: [
'path',
],
properties: {
path: {
// 相对于思源工作空间目录的文件/目录路径
type: 'string',
description: 'file/directory path relative to the SiYuan workspace directory',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/file/readDir/payload.schema.json",
"$comment": "v2.9.2",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "payload body",
"description": "list the contents of the specified file directory",
"type": "object",
"additionalProperties": false,
"required": [
"path"
],
"properties": {
"path": {
"type": "string",
"description": "file/directory path relative to the SiYuan workspace directory"
}
}
}
}
}
响应
ts
/**
* list the contents of the specified file directory
*/
export interface IResponse {
/**
* status code
*/
readonly code: number;
readonly data: IDatum[];
/**
* status message
*/
readonly msg: string;
}
/**
* response data
*
* file or directory
*/
export interface IDatum {
/**
* whether the item is a directory
*/
readonly isDir: boolean;
/**
* whether the item is a symbolic link
*/
readonly isSymlink: boolean;
/**
* file/directory name
*/
readonly name: string;
/**
* file/directory last modified time (Unix timestamp, seconds)
*/
readonly updated: number;
}
json5
/**
* schemas/kernel/api/file/readDir/response.schema.json5
* 列出指定文件目录下的内容
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#list-files
* REF: https://github.com/siyuan-note/siyuan/blob/v2.10.0/kernel/api/file.go#L135-L192
* @pathname: /api/file/readDir
* @version: 2.10.0
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/file/readDir/response.schema.json5',
$comment: 'v2.10.0',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'response body',
description: 'list the contents of the specified file directory',
type: 'object',
additionalProperties: false,
required: [
'code',
'msg',
'data',
],
properties: {
code: {
type: 'integer',
description: 'status code',
},
msg: {
type: 'string',
description: 'status message',
},
data: {
$ref: '#/$defs/data',
},
},
},
data: {
title: 'IData',
description: 'response data',
type: 'array',
items: {
$ref: '#/$defs/datum',
},
},
datum: {
title: 'IDatum',
description: 'file or directory',
type: 'object',
additionalProperties: false,
required: [
'isDir',
'isSymlink',
'name',
'updated',
],
properties: {
isDir: {
// 是否为文件夹
type: 'boolean',
description: 'whether the item is a directory',
},
isSymlink: {
// 是否为符号链接
type: 'boolean',
description: 'whether the item is a symbolic link',
},
name: {
// 文件/文件夹名称
type: 'string',
description: 'file/directory name',
},
updated: {
// 文件/文件夹最后修改时间
type: 'integer',
description: 'file/directory last modified time (Unix timestamp, seconds)',
examples: [
1663298365,
],
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/file/readDir/response.schema.json",
"$comment": "v2.10.0",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "response body",
"description": "list the contents of the specified file directory",
"type": "object",
"additionalProperties": false,
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "status code"
},
"msg": {
"type": "string",
"description": "status message"
},
"data": {
"$ref": "#/$defs/data"
}
}
},
"data": {
"title": "IData",
"description": "response data",
"type": "array",
"items": {
"$ref": "#/$defs/datum"
}
},
"datum": {
"title": "IDatum",
"description": "file or directory",
"type": "object",
"additionalProperties": false,
"required": [
"isDir",
"isSymlink",
"name",
"updated"
],
"properties": {
"isDir": {
"type": "boolean",
"description": "whether the item is a directory"
},
"isSymlink": {
"type": "boolean",
"description": "whether the item is a symbolic link"
},
"name": {
"type": "string",
"description": "file/directory name"
},
"updated": {
"type": "integer",
"description": "file/directory last modified time (Unix timestamp, seconds)",
"examples": [
1663298365
]
}
}
}
}
}
removeFile
- 🔥 删除 文件/目录
/api/file/removeFile
请求
ts
/**
* remove file/directory under the workspace directory
*/
export interface IPayload {
/**
* the file/dir path under the workspace path
*/
readonly path: string;
}
json5
/**
* schemas/kernel/api/file/removeFile/payload.schema.json5
* 移除工作区目录下指定的文件/目录
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#remove-file
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/file.go#L219-L249
* @pathname: /api/file/removeFile
* @version: 2.9.3
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/file/removeFile/payload.schema.json5',
$comment: 'v2.9.3',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'payload body',
description: 'remove file/directory under the workspace directory',
type: 'object',
additionalProperties: false,
required: [
'path',
],
properties: {
path: {
// 相对于思源工作空间目录的文件/目录路径
type: 'string',
description: 'the file/dir path under the workspace path',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/file/removeFile/payload.schema.json",
"$comment": "v2.9.3",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "payload body",
"description": "remove file/directory under the workspace directory",
"type": "object",
"additionalProperties": false,
"required": [
"path"
],
"properties": {
"path": {
"type": "string",
"description": "the file/dir path under the workspace path"
}
}
}
}
}
响应
ts
/**
* remove file/directory under the workspace directory
*/
export interface IResponse {
/**
* status code
*/
readonly code: number;
readonly data: null;
/**
* status message
*/
readonly msg: string;
}
json5
/**
* schemas/kernel/api/file/removeFile/response.schema.json5
* 移除工作区目录下指定的文件/目录
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#remove-file
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/file.go#L219-L249
* @pathname: /api/file/removeFile
* @version: 2.9.3
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/file/removeFile/response.schema.json5',
$comment: 'v2.9.3',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'response body',
description: 'remove file/directory under the workspace directory',
type: 'object',
additionalProperties: false,
required: [
'code',
'msg',
'data',
],
properties: {
code: {
type: 'integer',
description: 'status code',
},
msg: {
type: 'string',
description: 'status message',
},
data: {
type: 'null',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/file/removeFile/response.schema.json",
"$comment": "v2.9.3",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "response body",
"description": "remove file/directory under the workspace directory",
"type": "object",
"additionalProperties": false,
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "status code"
},
"msg": {
"type": "string",
"description": "status message"
},
"data": {
"type": "null"
}
}
}
}
}
renameFile
- 🔥 重命名/移动 文件/目录
/api/file/renameFile
请求
ts
/**
* remove file/directory under the workspace directory
*/
export interface IPayload {
/**
* the new file/dir path under the workspace path
*/
readonly newPath: string;
/**
* the file/dir path under the workspace path
*/
readonly path: string;
}
json5
/**
* schemas/kernel/api/file/renameFile/payload.schema.json5
* 重命名/移动工作空间目录下的文件/目录
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#rename-file
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/file.go#L184-L217
* @pathname: /api/file/renameFile
* @version: 2.9.3
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/file/renameFile/payload.schema.json5',
$comment: 'v2.9.3',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'payload body',
description: 'remove file/directory under the workspace directory',
type: 'object',
additionalProperties: false,
required: [
'path',
'newPath',
],
properties: {
path: {
// 相对于思源工作空间目录的文件/目录路径
type: 'string',
description: 'the file/dir path under the workspace path',
},
newPath: {
// 相对于思源工作空间目录的文件/目录新路径
type: 'string',
description: 'the new file/dir path under the workspace path',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/file/renameFile/payload.schema.json",
"$comment": "v2.9.3",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "payload body",
"description": "remove file/directory under the workspace directory",
"type": "object",
"additionalProperties": false,
"required": [
"path",
"newPath"
],
"properties": {
"path": {
"type": "string",
"description": "the file/dir path under the workspace path"
},
"newPath": {
"type": "string",
"description": "the new file/dir path under the workspace path"
}
}
}
}
}
响应
ts
/**
* remove file/directory under the workspace directory
*/
export interface IResponse {
/**
* status code
*/
readonly code: number;
readonly data: null;
/**
* status message
*/
readonly msg: string;
}
json5
/**
* schemas/kernel/api/file/renameFile/response.schema.json5
* 重命名/移动工作空间目录下的文件/目录
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#rename-file
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/file.go#L184-L217
* @pathname: /api/file/renameFile
* @version: 2.9.3
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/file/renameFile/response.schema.json5',
$comment: 'v2.9.3',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'response body',
description: 'remove file/directory under the workspace directory',
type: 'object',
additionalProperties: false,
required: [
'code',
'msg',
'data',
],
properties: {
code: {
type: 'integer',
description: 'status code',
},
msg: {
type: 'string',
description: 'status message',
},
data: {
type: 'null',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/file/renameFile/response.schema.json",
"$comment": "v2.9.3",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "response body",
"description": "remove file/directory under the workspace directory",
"type": "object",
"additionalProperties": false,
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "status code"
},
"msg": {
"type": "string",
"description": "status message"
},
"data": {
"type": "null"
}
}
}
}
}