api.tools

readDocument()

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

Lee uno dei files del conto indietro, contenuto incluso. Libera, e la stessa chiamata come 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.

Parâmetros

sourceIdstringobrigatório

L'identificator da listDocuments() o da un salva. Mancando leva imediatamente.

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

Ce torna

Un IaGenifyFile — il medesimo objeto api.files.create() ti manda, ya portando il suo sourceId. Quindi ler, cambiare e riporlo è tre righe.

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

Nome del dossier.

contentstring | Buffer

Texte come una string; qualquer altra cosa como un Buffer.

mimeTypestring

Coma quels fuse salvat.

sourceIdstring

Ya set — update() funcionà istanzion.

location · metadataobject

Onde vive, e che cosa è registrat al suo sobre.

Como un utensilio, il cadèn a un sentiero tambèn

Un parametro, due tipos de valore

Dichiarat a un model, il parametro è chiamato documente e accetta o un id o un perit sul computer del caller. Un id è tentat prima; a sfascia, il perit è let a la macchina attraverso il pacchetto. Un utensiliu per ambeds lati, perché un model non deve saper che sta sostenendo.

Un file binario letçâ di quel modo è reportat come binario e non restituit como una stringa disgregada — al modele è dito il nome, il tipo e il tamaño, e poten a chiedere una conversione in lugar.

Erros

CódigoStatusQuando
file_not_found404Nessuna tal file su este cont.
file_missing_on_disk404Il record è là e i bytes non lo sono.

Un appello con no sourceId lance prima di ogni richiesta: è un erro nel vostro codice, non una risposta da plataforma.