files()
Downloads the files of a document object from the server via std.StoreInCacheById.
When version_guid is provided, the files of a specific previous version are
retrieved via std.GetDocVersion instead.
The document can be passed as a model instance or directly as a numeric ID.
Files can optionally be converted before transfer or have annotations burned in.
1. Signature
-
Sync
-
Async
ecm.dms.files(
model: ECMDocumentModel | int,
*,
flags: int = 1,
convert: StoreInCacheByIdConversion = StoreInCacheByIdConversion.NONE,
when_cold_then_tiff: bool = False,
add_annotations: bool = False,
version_guid: str | None = None,
) -> list[JobResponseFile]
await ecm.dms.files(
model: ECMDocumentModel | int,
*,
flags: int = 1,
convert: StoreInCacheByIdConversion = StoreInCacheByIdConversion.NONE,
when_cold_then_tiff: bool = False,
add_annotations: bool = False,
version_guid: str | None = None,
) -> list[JobResponseFile]
2. Parameters
| Parameter | Default | Description |
|---|---|---|
|
— |
|
|
|
Controls which files are transferred:
|
|
|
Optional conversion applied before transfer (
|
|
|
When |
|
|
When |
|
|
Optional GUID of a specific document version. When provided, the files of that version are returned via |
3. Return value
A list of JobResponseFile objects. Small files are kept as a byte array in memory;
larger files are written to a temporary file on the filesystem.
Properties and methods of JobResponseFile:
| Property / Method | Description |
|---|---|
|
Filename including extension (e.g. |
|
File extension (e.g. |
|
File size in bytes. |
|
File content as |
|
Write the file to disk. Without |
5. Examples
5.1. Load files from a model instance
-
Sync
-
Async
document = ecm.dms.get(InvoiceDocument, 12345)
for f in ecm.dms.files(document):
print(f.name, f.size())
content = f.bytes()
document = await ecm.dms.get(InvoiceDocument, 12345)
for f in await ecm.dms.files(document):
print(f.name, f.size())
content = f.bytes()
5.2. Load files by plain ID
If the document ID is known, the object does not need to be fully loaded:
-
Sync
-
Async
for f in ecm.dms.files(12345):
print(f.name, f.size())
for f in await ecm.dms.files(12345):
print(f.name, f.size())
5.3. Load as PDF
Documents with main types 1–4 are converted to PDF on the server before transfer:
-
Sync
-
Async
from ecmind_blue_client import StoreInCacheByIdConversion
files = ecm.dms.files(12345, convert=StoreInCacheByIdConversion.PDF)
pdf = files[0]
print(pdf.name) # e.g. "invoice.pdf"
pdf.store("/tmp/invoice.pdf")
from ecmind_blue_client import StoreInCacheByIdConversion
files = await ecm.dms.files(12345, convert=StoreInCacheByIdConversion.PDF)
pdf = files[0]
pdf.store("/tmp/invoice.pdf")
5.4. Load as multi-page TIFF
TIFF documents (main types 2 or 3) are merged into a single multi-page TIFF file:
-
Sync
-
Async
from ecmind_blue_client import StoreInCacheByIdConversion
files = ecm.dms.files(12345, convert=StoreInCacheByIdConversion.MULTIPAGE_TIFF)
tiff = files[0]
tiff.store("/tmp/document.tiff")
from ecmind_blue_client import StoreInCacheByIdConversion
files = await ecm.dms.files(12345, convert=StoreInCacheByIdConversion.MULTIPAGE_TIFF)
tiff = files[0]
tiff.store("/tmp/document.tiff")
5.5. Load with burned-in annotations
-
Sync
-
Async
files = ecm.dms.files(12345, add_annotations=True)
for f in files:
f.store(f"/tmp/{f.name}")
files = await ecm.dms.files(12345, add_annotations=True)
for f in files:
f.store(f"/tmp/{f.name}")
5.6. Load files from a previous version
The version_guid is obtained from the object’s history. Look for entries with
action VERSION_CREATED:
-
Sync
-
Async
from ecmind_blue_client.ecm import ECMHistoryAction
history = ecm.dms.history(12345)
versions = [e for e in history.entries if e.action == ECMHistoryAction.VERSION_CREATED]
if versions:
# Load files from the oldest version
old_version = versions[-1]
files = ecm.dms.files(12345, version_guid=old_version.guid)
for f in files:
print(f.name, f.size())
from ecmind_blue_client.ecm import ECMHistoryAction
history = await ecm.dms.history(12345)
versions = [e for e in history.entries if e.action == ECMHistoryAction.VERSION_CREATED]
if versions:
old_version = versions[-1]
files = await ecm.dms.files(12345, version_guid=old_version.guid)
for f in files:
print(f.name, f.size())
5.7. Download all files from a query result
-
Sync
-
Async
import os
output_dir = "/tmp/invoices"
os.makedirs(output_dir, exist_ok=True)
for doc in ecm.dms.select(InvoiceDocument).where(InvoiceDocument.Year == 2024).stream():
for f in ecm.dms.files(doc):
f.store(os.path.join(output_dir, f"{doc.system.id}_{f.name}"))
import os
output_dir = "/tmp/invoices"
os.makedirs(output_dir, exist_ok=True)
async for doc in ecm.dms.select(InvoiceDocument).where(InvoiceDocument.Year == 2024).stream():
for f in await ecm.dms.files(doc):
f.store(os.path.join(output_dir, f"{doc.system.id}_{f.name}"))