形状很不寻常,值得一句话 create() 任何地方,都不能造任何物。它能把你们所填满的东西,和所装的,交给你们。 save() 是什么到达服务器。分离就是让同一个对象写入磁盘、账户或两者。
表面表面
| 调用 | 功能 | 费用 |
|---|---|---|
| api.files.create({ name, content, mimeType }) | 构建文件对象。无网络。 | 无 |
| file.save({ storageId, path, localOnly }) | 写下来——到帐户,到磁盘,或两者兼有。 | 1个信贷信贷 |
| file.update() | 替换已保存的内容。 | 无 |
| api.files.get(sourceId) | 背面读一行,内容包含在内。 | 无 |
| api.files.list() | 账户上的所有文件 | 无 |
| api.files.delete(sourceId) | 把它和索引中的东西删除。 | 无 |
结束至结束
// 1. Build it — nothing has happened yet
const file = api.files.create({
name: "report.md",
content: "# Q4\n\nRevenue was…",
mimeType: "text/markdown",
});
// 2. Save it — this is the call that spends
const saved = await file.save();
saved.sourceId; // how you will find it again
file.sourceId; // the object learned its own id
// 3. Read it back, anywhere
const again = await api.files.get(saved.sourceId);
again.content; // "# Q4\n\nRevenue was…"
// 4. Replace its content
again.content = "# Q4\n\nRevised.";
await again.update();
// 5. Remove it
await api.files.delete(saved.sourceId);# 1. Build it — nothing has happened yet
file = api.files.create(
name="report.md",
content="# Q4\n\nRevenue was…",
mime_type="text/markdown",
)
# 2. Save it — this is the call that spends
saved = file.save()
saved["sourceId"] # how you will find it again
file.source_id # the object learned its own id
# 3. Read it back, anywhere
again = api.files.get(saved["sourceId"])
again.content # "# Q4\n\nRevenue was…"
# 4. Replace its content
again.content = "# Q4\n\nRevised."
again.update()
# 5. Remove it
api.files.delete(saved["sourceId"])档案实际去到哪里
除非您指定另一个 storageId。一种储存方式根本无法使用。
电脑或电话保存自己的文件
拒绝通过服务器保存到一个服务器 storage_is_local,在任何功率用完之前——不是失败,而是声明:那些字节生活在该装置上,读写从装置本身上。
意味着 api.files 用于账户中的文件。对于机器自己的文件,请参见 本地文件; 对于物件存储内容, storage.run().
类别是推断的,没有申报
| MIME 类型 | 类别 |
|---|---|
| 图像/ * | 图像图像图像图像 |
| 音音/* | 音频 |
| 视频/* | 视频视频 |
| json · 山地山地山地山地山地山地山地山地山地山地山地山地山地山地山地山地山地山地山地山地山地山地山地山地山地山地山地山地山地山地山地山地山地山地山地山地山地 | 数据数据数据数据数据 |
| 任何其他内容 | 文档文档文档文档 |
之所以重要,原因只有一个:a document 保存后, 将用于语义搜索, 以便稍后找到。 其它的都不存在 。
在你发扬光大之前 值得知道的两件事
- 节省一个信贷成本,如果写作失败,则全额退款。阅读、列出和删除不花费任何费用。
- 文件对象是您填充的控件 。
create()永远也不要触碰网络,save().