Skip to content

保存/编辑文件内容

保存文本内容到指定文件,用于在线编辑代码或配置文件。

POST
https://your-panel.example.com:8888/files
更新于 查看 Markdown

Request bodyX-WWW-FORM-URLENCODEDrequired

  • request_timestringrequired

    Unix 时间戳。

  • request_tokenstringrequired

    按 API 概览生成的签名。

  • actionSaveFileBodyrequired

    具体操作名称。

  • pathstringrequired

    文件绝对路径

  • datastringrequired

    要写入的文件内容

  • encodingstringrequired

    文件编码:utf-8 / ascii / ansi / GBK / BIG5

Returns

default

接口响应,业务状态见下方详细说明。

JSON
  • statusoptionalboolean

    true 保存成功

  • msgoptionalstring

    文件已保存!

  • historysoptionalarray ofunknown

    历史版本 ID 列表

  • st_mtimeoptionalstring

    修改时间戳

各操作详细说明

SaveFileBodyaction=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"}

相关接口

Navigation

Type to search…

↑↓ navigate↵ selectEsc close