写入文件
先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
PUT
/sandbox/v1/sandboxes/{sandbox_id}/files● 支持请求参数
sandbox_idstring必填path: Sandbox ID returned by sandboxes.create or sandboxes.list.
pathstring必填File or directory path inside the sandbox; relative paths use the user's home directory.
datastring必填UTF-8 text to write, replacing existing content.
返回
200
错误按 E2B 格式返回,参见 错误码
请求示例
curl
# 先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
curl -X PUT https://api.deepraxis.com/sandbox/v1/sandboxes/sbx_123/files \
-H "X-API-Key: $PRAXIS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"path":"/tmp/docs-files/hello.txt","data":"Hello from Praxis!"}'Python
# 先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
import requests
api_key = "$PRAXIS_API_KEY"
# Call /sandbox/v1 directly over HTTP.
resp = requests.put(
"https://api.deepraxis.com/sandbox/v1/sandboxes/sbx_123/files",
headers={"X-API-Key": api_key},
json={"path": "/tmp/docs-files/hello.txt", "data": "Hello from Praxis!"},
)
print(resp.status_code, resp.text)TypeScript
// 先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
const apiKey = "$PRAXIS_API_KEY";
// Call /sandbox/v1 directly over HTTP.
const resp = await fetch(`https://api.deepraxis.com/sandbox/v1/sandboxes/sbx_123/files`, {
method: "PUT",
headers: { "X-API-Key": apiKey, "Content-Type": "application/json" },
body: JSON.stringify({ path: "/tmp/docs-files/hello.txt", data: "Hello from Praxis!" }),
});
console.log(resp.status, await resp.text());响应示例 200
{
"name": "hello.txt",
"path": "/tmp/docs-files/hello.txt",
"size": 0,
"type": "file"
}响应
HTTP 200
Operation completed
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| name | string | Entry basename. |
| path | string | Entry path in the sandbox. |
| type | string | file is a regular file, dir a directory, symlink a symbolic link. |
| size | number | Entry size in bytes. |