api.tools

readDocument()

api.tools.readDocument(sourceId) → Promise<IaGenifyFile>

读取账户的文档中的 文档, 内容包含在内。 免费, 和相同的电话 api.files.get().

GET /api/files/:idfreecontent included
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

参数

sourceIdstring必填

识别身份来自 列表文档() 或从一个储蓄中。 失踪立即起降。

const [first] = await api.tools.listDocuments();
const file = await api.tools.readDocument(first.id);

console.log(file.name, file.mimeType);
console.log(file.content);              // a string for text, a Buffer otherwise
first = api.tools.list_documents()["account"][0]
file = api.tools.read_document(first["id"])

print(file.name, file.mime_type)
print(file.content)              # a str for text, bytes otherwise

回到什么

A 音 A Ia 化文件 - 同一目的 api.files.create() 手已经牵手,手已经牵手 sourceId读取,改变和放回三行

const file = await api.tools.readDocument(id);
file.content = `${file.content}\n\nReviewed on ${new Date().toISOString().slice(0, 10)}.`;
await file.update();                    // replaces it, same sourceId
from datetime import date

file = api.tools.read_document(source_id)
file.content = f"{file.content}\n\nReviewed on {date.today().isoformat()}."
file.update()                    # replaces it, same source_id
namestring

档案的名字

contentstring | Buffer

文本为字符串; 其它任何文本为缓冲。

mimeTypestring

保存下来的是什么

sourceIdstring

已经设置 - update() 工作马上进行

location · metadataobject

住在哪里 记录到什么

作为一种工具,它也走一条路

一种参数,两种数值

被宣布为模型, 其参数被称为文档, 它接受调用器计算机上的代号或路径。 先试 id; 否则, 则通过软件包在机器上读取路径 。 双方都使用一个工具, 因为模型不应该知道它持有的是什么 。

以这种方式读取的二进制文件被报告为二进制文件,而不是以混杂字符串返回——模型被告知名称、类型和大小,可以要求转换。

错误

代码状态触发条件
file_not_found404此账户上没有此文件 。
file_missing_on_disk404记录在记录中,字节不在记录中。

打电话时没有 sourceId 在任何请求之前丢弃: 错误的代码, 而不是平台的回答 。