你从不建建建筑,就是 storage.files 将他的手放在一个仓库上, type 是 filesystem而不是归还空空的名单——见 文件 文件.
六种方法
| 调用 | 功能 | 回报 |
|---|---|---|
| 列表( dir, 选项) | 读取文件夹 。 | 一系列项目 。 |
| mkdir( 目录) | 创建文件夹, 包括父文件夹 。 | 文件夹项 。 |
| (文件、内容) | 写了档案 包括父母 | 文件项 。 |
| (文件已读) | 读取文件 。 | 项目,加上 content. |
| (从、 移动到) | 移动或重命名。 | 在其新路径的项目 。 |
| 删除( 目标) | 删除文件或文件夹及其内容。 | { ok: true }. |
结束至结束
const pc = await api.storage.get(); // the computer this process is on
await pc.files.mkdir("Launch plan");
await pc.files.write("Launch plan/brief.md", "# Brief\n\nShip in March.");
const brief = await pc.files.read("Launch plan/brief.md");
console.log(brief.content); // a string: it is text
for (const item of await pc.files.list("Launch plan")) {
console.log(item.type, item.path, item.size);
}pc = api.storage.get() # the computer this process is on
pc.files.mkdir("Launch plan")
pc.files.write("Launch plan/brief.md", "# Brief\n\nShip in March.")
brief = pc.files.read("Launch plan/brief.md")
print(brief["content"]) # a str: it is text
for item in pc.files.list("Launch plan"):
print(item["type"], item["path"], item["size"])工作空间
用户主目录中所有事物都发生在一个文件夹下: ~/.iagenify/files。它首先使用时创建,只有所有人可以读取,并且由使用软件包的机器上的所有应用程序共享。所以用脚本书写的文件就是代理阅读的文件。
没有当前要更改的目录, 也没有方法给上面的文件夹命名 。 路径是工作空间内的位置, 也就是让路径能够安全地从模型或窗体中接受 。
道路可能是什么
| 书面 | 结果成果成果成果成果成果成果成果成果 |
|---|---|
notes.md | 工作空间顶部的文件 。 |
Launch plan/brief.md | 套套,每个系统都向前冲 |
Launch\\plan/brief.md | 后鞭正常为前鞭。 |
"" (空) | 工作空间本身。 list 仅此而已。 |
/etc/passwd · C:/Windows | 拒绝: invalid_path. |
../../secrets | 拒绝: invalid_path,在决议通过后。 |
支票是用 已解决 而不是在文本上:一条从中爬出来又回来的路是好的,一条看起来无害,但外部土地却被拒绝的道路。
形状 每一个方法返回
// A file
{
name: "brief.md",
path: "Launch plan/brief.md", // relative to the workspace, forward slashes
type: "file",
size: 1284, // bytes
mimeType: "text/markdown", // from the extension
modifiedAt: "2026-10-07T09:12:44.000Z"
}
// A folder — size and mimeType are null
{ name: "Launch plan", path: "Launch plan", type: "folder", size: null, mimeType: null, modifiedAt: "…" }# A file
{
"name": "brief.md",
"path": "Launch plan/brief.md", # relative to the workspace, forward slashes
"type": "file",
"size": 1284, # bytes
}
# A folder — size is 0
{"name": "Launch plan", "path": "Launch plan", "type": "folder", "size": 0}隐藏条目被遗漏
任何以点开头的名字从 list()。 这正是将两个文件夹保存在 代理在幕后写作的幕后—— 保存的版本保存在 .versions/ 循环桶下 .trash/ ——不列入清单,但如果需要,则保留姓名可读。
// Not in list(), but readable
const previous = await pc.files.list(".versions/notes.md");
const bin = await pc.files.list(".trash");# Python's list() hides dot folders; read them from the workspace root directly
previous = sorted((pc.files.root / ".versions" / "notes.md").glob("*"))
trash = sorted((pc.files.root / ".trash").glob("*"))需要一张磁盘,右面的磁盘
两名警卫在任何方法接触文件系统之前都跑, 两者都抛出而不是降低。
local_files_require_node浏览器和工人用不同的方式到达自己的存储库。storage_not_on_this_machine-你手上的存储器属于另一台电脑 并且它的文件在那台电脑上
api.storage.list() 将每个电脑都交回账户, 包括你没有坐过的那些电脑。 第二名警卫将这变成一个明显的拒绝, 而不是一个错误的磁盘读取。
import { IaGenifyError } from "iagenify";
const computers = (await api.storage.list()).filter((s) => s.type === "filesystem");
for (const computer of computers) {
try {
await computer.files.list();
} catch (err) {
if (err instanceof IaGenifyError && err.code === "storage_not_on_this_machine") {
console.log(`${computer.label} is elsewhere — skipping.`);
continue;
}
throw err;
}
}# A computer that is not this one has files = None in Python
computers = [s for s in api.storage.list() if s.type == "filesystem"]
for computer in computers:
if computer.files is None:
print(f"{computer.label} is elsewhere — skipping.")
continue
computer.files.list()机器没有留下什么
这里没有方法可以请求。 上传的没有什么可以阅读, 没有索引, 也没有使用信用。 账户知道这台计算机注册为存储器, 它不知道里面有什么 。