Attachments include images, documents and other files stored in eagle.io. New attachments can be manually uploaded by a user or acquired via an attachment source. Attachments can be added inside workspaces, locations, groups and attachment sources.
Once you have attachments, they can be viewed via the attachments view. In this example we have 6 attachments at various places in the workspaces tree:
And these are the 6 attachments viewed via the attachments view:
Attachments can be downloaded manually by clicking the blue arrow on the right side of the attachments view. And if you need to download attachments programmatically, a download link can be determined via the API. The attachment source in this example has an ID of 6181fbdd5584e0fb6d9055be
, and the following API query can be used to list the 3 attachments it contains:
https://api.eagle.io/api/v1/nodes/?filter=_class($eq:io.eagle.models.node.Attachment),parentId($eq:6181fbdd5584e0fb6d9055be
)&attr=fileUrl,name,createdTime,description
Note that this is a node query, but is filtered to specify only nodes of the io.eagle.models.node.Attachment
class, with a particular parentId
(which is the ID of the node containing the attachments, in this case the attachment source). The query also specifies that only certain attributes of the attachment nodes should be returned; in this case, we want to see the name
, createdTime
and (optional) description
of each attachment node, and because we ultimately want to download attachments as files, we also need the fileUrl
attribute.
The query returns a list of the 3 attachment nodes that are contained by the attachment source:
The URLs can then be used to download a copy of the actual .dat
files.
Attachments may not be located just within attachment sources; they can also be manually uploaded within workspaces, locations and groups. The API query above could specify any node as the parentId
, and any attachments directly contained by that node will be returned by the query. However, if you needed to list all attachments in the workspace, the query can be modified to specify the workspaceId
instead of the parentId
:
https://api.eagle.io/api/v1/nodes/?filter=_class($eq:io.eagle.models.node.Attachment),workspaceId($eq:614c26e0168636df03a869e8)&attr=fileUrl,name,createdTime,description
This query will return a longer list, containing all 6 attachments regardless of their position within the workspace:
A final note: if you are using these types of queries to regularly download attachments, it's likely desirable for each query to list only attachments that have been created since the previous query. This can prevent the inefficiency of downloading identical files repeatedly.
To achieve this, they query filter can include a createdTime
in order to list only those attachments that have been created since a specified time.
Comments
0 comments
Article is closed for comments.