api.files

get()

api.files.get(sourceId) → Promise<IaGenifyFile>

يقرأ a ملفّ مع المحتوى نص a سلسلة أيّ شئ آخر ك بايت و كائن هو جاهز إلى تحديث.

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مطلوب

من طراز (أ) أو )أ(ثالثاً - SDK رميات.

القيمة المُعادة

const file = await api.files.get(sourceId);

file.name;       // "report.md"
file.mimeType;   // "text/markdown"
file.content;    // a string, here — a Buffer for binary
file.sourceId;   // set, so update() works straight away
file.location;   // the kind of storage it is in
file.metadata;   // { size, mimeType, originalName }
file = api.files.get(source_id)

file.name        # "report.md"
file.mime_type   # "text/markdown"
file.content     # a str, here — bytes for binary
file.source_id   # set, so update() works straight away
file.location    # the kind of storage it is in
file.metadata    # {"size", "mimeType", "originalName"}

ساط أو طرفات، مُقررة على هذا النوع

A ملفّ الذي نوع نوع نوعه نصي - يُرجع كـ a سلسلة نصّ، كلّ شيء آخر كـ a Buffer.

مُمTypeالضم
* / / / / / / / / / / / / / / / / x / x / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / - - - - - - - - - - - - - - - - - - - - - - - - -هذا
:: ما هو آخر)أ(
const file = await api.files.get(sourceId);

if (typeof file.content === "string") {
  console.log(file.content.slice(0, 200));
} else {
  await fs.writeFile(`./${file.name}`, file.content);
}
from pathlib import Path

file = api.files.get(source_id)

if isinstance(file.content, str):
    print(file.content[:200])
else:
    Path(file.name).write_bytes(file.content)
القرار هو النوع، ليس إلى

A نص ملفّ محفوظ بدون a مِيّمType يعود كa buver. ضبط نوع عند إ_ نشئ و هذا لا يأتي.

إنها تقرأ كامل الملف

لا يوجد مجال ولا أي مجال أو تدفق: المحتوى يصل في رد واحد، كنص أو كأساس 64 SDK لَكَ ، لَمْ تَكُنْ مُسْتَقْبَلَةً كَبِيرَةً ، هِيَ ذِكْرَةٌ مِنْ كِلَا الطرفين — قَمْحَهَا قَبْلَ أَنْ تَجْلُبَهَا .

const files = await api.files.list();
const target = files.find((f) => f.id === sourceId);

if (target.size > 20 * 1024 * 1024) {
  throw new Error(`${target.name} is ${Math.round(target.size / 1e6)} MB — too big to read in one go`);
}

const file = await api.files.get(sourceId);
files = api.files.list()
target = next(f for f in files if f["id"] == source_id)

if target["size"] > 20 * 1024 * 1024:
    raise ValueError(f"{target['name']} is {round(target['size'] / 1e6)} MB — too big to read in one go")

file = api.files.get(source_id)

الأخطاء

الرمزالحالةمتى
— (يُطلَق محليًا)—لم يمر أي مصدر
file_not_found404لا ملف لهذا الحساب مع هوية.
file_missing_on_disk404السجل موجود و لا توجد أي سجلاته
file_missing_on_disk قيمة ملاحظة ، لا إعادة إعادة

الـ سجل و إلى تفتت. إعادة المحاولة أجوبة نفس الشيء. ما يساعد هو حذف السجل و حفظ الملف مرة أخرى.

ملف يعود إلى حساب آخر يجيب نفسه 404كل بحث يتم تنظيمه للمتصل