Attachments Class

Attachments interface

Direct access to the attachments endpoint

The user is not expected to use this class directly. It is an attribute of the Archivist class.

For example instantiate an Archivist instance and execute the methods of the class:

with open(".auth_token", mode="r", encoding="utf-8") as tokenfile:
    authtoken =

# Initialize connection to Archivist
arch = Archivist(
with open("something.jpg") as fd:
    attachment = arch.attachments.upload(fd)
class archivist.attachments.Attachment[source]

Attachment object has dictionary attributes.

class archivist.attachments._AttachmentsClient(archivist_instance: archivist.Archivist)[source]


Access to attachments entities using CRUD interface. This class is usually accessed as an attribute of the Archivist class.


archivist (Archivist) -- Archivist instance

create(data: dict[str, Any]) dict[str, Any][source]

Create an attachment and return struct suitable for use in an asset or event creation.


data (dict) -- dictionary

A YAML representation of the data argument would be:

filename: functests/test_resources/doors/assets/gdn_front.jpg
content_type: image/jpg
display_name: arc_primary_image


   content_type: application/zip
   display_name: Test malware

Either 'filename' or 'url' is required.
'content_type' is required.

A dict suitable for adding to an asset or event creation

A YAML representation of the result would be:

arc_display_name: Telephone
arc_blob_identity: blobs/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
arc_blob_hash_alg: SHA256
arc_blob_hash_value: xxxxxxxxxxxxxxxxxxxxxxx
arc_file_name: gdn_front.jpg
download(identity: str, fd: BinaryIO, *, params: Optional[dict[str, Any]] = None) Response[source]

Read attachment

Reads attachment into data sink (usually a file opened for write).. Note that returns the response as the body will be consumed by the fd iterator

  • identity (str) -- attachment identity e.g. blobs/xxxxxxxxxxxxxxxxxxxxxxx

  • fd (file) -- opened file descriptor or other file-type sink..

  • params (dict) -- e.g. {"allow_insecure": "true"} OR {"strict": "true" }


JSON as dict

get_default_key(data: dict[str, str]) str[source]

Return a key to use if no key was provided either use filename or url as one of them is required

info(identity: str) dict[str, Any][source]

Read attachment info

Reads attachment info


identity (str) -- attachment identity e.g. blobs/xxxxxxxxxxxxxxxxxxxxxxx


REST response

upload(fd: BinaryIO, *, mtype: Optional[str] = None) Attachment[source]

Create attachment

Creates attachment from opened file or other data source.

  • fd (file) -- opened file descriptor or other file-type iterable.

  • mtype (str) -- mimetype of data.


Attachment instance