Skip to main content
  • Sync
  • Async
def get_document_file(
    document_id: str,
) -> bytes

Parameters

  • document_id (str): ID of the document to download

Returns

  • bytes: Raw file content as bytes

Examples

  • Sync
  • Async
from morphik import Morphik

db = Morphik()

# Download a document's raw file
doc_id = "doc_123abc"
file_content = db.get_document_file(doc_id)

# Save to local file
with open("downloaded_file.pdf", "wb") as f:
    f.write(file_content)

print(f"Downloaded {len(file_content)} bytes")

Notes

  • This method returns the raw file bytes, which you can save to disk or process in memory.
  • For getting a downloadable URL instead of raw bytes, use get_document_download_url.
  • The returned bytes match the original file that was uploaded/ingested.