Add Attachments to a Structured Document - Fluid Topics - 3.9 - Technical Notes

Develop Connectors with the Fluid Topics API

Product
Fluid Topics
Fluid Topics Version
3.9
Category
Technical Notes
Language
English
Target Audience
public

An Attachment is a file (e.g. PDF, image, video, JavaScript, etc.) or a URL attached to a structured document.

The following lines show how to add locally and externally sourced attachments:

from fluidtopics.connector import StructuredDocument, Attachment

# Attachment creation
attachment = Attachment.from_uri(
attachment_id="my-attachment",
uri="/local/path/to/my/attachment.zip",
title="My Attachment"
)

# External attachment creation
external_attachment = Attachment(
attachment_id="my-external-attachment",
title="FT Global Presence",
mime_type="video/mpeg",
url="https://www.youtube.com/watch?v=hsXwJb-agsQ"
)

book = StructuredDocument.create(
document_id="my-structured-document",
title="My Structured Document",
locale="en-US",
toc=[topic_A, topic_B],
attachments=[attachment, external_attachment]
)

The following screenshot shows how attachments are displayed in the Reader page sidebar:

attachments