Appearance
编辑文件
对指定文件进行字符串替换编辑。old_string 必须在文件中存在,new_string 为空时等同于删除 old_string。
- 接口路径:
POST /v1/openapi/app/files/edit
请求头
| 参数名 | 必填 | 说明 |
|---|---|---|
| Content-Type | 是 | application/json |
| Authorization | 是 | 鉴权凭证,格式 Bearer sk_xxx |
请求参数
json
{
"user_id": "user123",
"path": "/data/file.txt",
"old_string": "hello world",
"new_string": "hello Go",
"replace_all": false
}| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| user_id | string | 是 | 业务方用户 ID,用于确定所属工作空间 |
| path | string | 是 | 文件路径 |
| old_string | string | 是 | 待替换的原始字符串,必须在文件中存在 |
| new_string | string | 否 | 替换后的新字符串,默认为空(即删除) |
| replace_all | bool | 否 | 是否替换所有匹配项,默认 false |
响应示例
json
{
"code": 200,
"data": {},
"message": "",
"trace_id": "stu901"
}