import fs from 'fs'
import { Sandbox } from 'ppio-sandbox/code-interpreter'
const sandbox = await Sandbox.create()
// 在沙箱内创建一个文件用于测试
const filePathInSandbox = '/tmp/test-file'
await sandbox.files.write(filePathInSandbox, "test-file-content")
// 从沙箱读取文件内容
const content = await sandbox.files.read(filePathInSandbox)
// 将文件写入本地文件系统
const localFilePath = './local-test-file'
fs.writeFileSync(localFilePath, content)
await sandbox.kill()
from ppio_sandbox.code_interpreter import Sandbox
sandbox = Sandbox.create()
# 在沙箱内创建一个文件用于测试
file_path_in_sandbox = '/tmp/test-file'
sandbox.files.write(file_path_in_sandbox, "test-file-content")
# 从沙箱读取文件内容
content = sandbox.files.read(file_path_in_sandbox)
# 将文件内容写入本地文件系统
local_file_path = './local-test-file'
with open(local_file_path, 'w') as file:
file.write(content)
sandbox.kill()