SaveFileBody
保存文本内容到指定文件,用于在线编辑代码或配置文件。
- 路由:
POST /files - action:
SaveFileBody
输入参数
| 参数名称 | 必选 | 类型 | 描述 |
|---|---|---|---|
| action | 是 | String | 固定值 SaveFileBody |
| path | 是 | String | 文件绝对路径 |
| data | 是 | String | 要写入的文件内容 |
| encoding | 是 | String | 文件编码:utf-8 / ascii / ansi / GBK / BIG5 |
重要:
encoding参数必须传入,否则会报FILE_SAVE_ERR错误。
输出参数
| 参数名称 | 类型 | 描述 |
|---|---|---|
| status | Boolean | true 保存成功 |
| msg | String | 文件已保存! |
| historys | Array | 历史版本 ID 列表 |
| st_mtime | String | 修改时间戳 |
示例
请求
POST /files HTTP/1.1
Host: 192.168.168.213:8888
Content-Type: application/x-www-form-urlencoded
action=SaveFileBody&path=/tmp/test.txt&data=hello world&encoding=utf-8
响应
{"status": true, "msg": "文件已保存!", "historys": ["1779514192"], "st_mtime": "1779514192"}
相关接口
- GetFileBody — 读取文件
- CreateFile — 创建文件