This article provides an overview and how-to instructions for working with attachments within Ditto. Attachments in Ditto are represented using the ATTACHMENT data type, which you can use to store binary data, such as images, alongside queryable descriptive information, such as file name and description.
Field | Detail | Description |
---|---|---|
id | Attachment ID | A cryptographic hash of the attachment’s binary contents. (See Organizing by ID) |
len | Blob Length | The size of the blob data in terms of length (len) in bytes. (See Blob Store) |
metadata | Metadata | Additional information about the attachment, such as its name, type, and so on. |
car_stock_photo.jpg
:
newAttachment
method on the store
namespace.
When creating an attachment...
An attachment token is...
123
in the cars collection. The attachment token is stored in the
my_attachment
field of the document.
Syncing with Big Peers
ATTACHMENT
object is created and linked to a document, it becomes immutable, meaning its contents cannot be changed.
However, you can indirectly update attachments by performing an UPDATE
operation on the document to replace the existing attachment token with a different one. The attachment token is the reference pointer linking the document to the attachment’s binary data stored separately.
Approach | Description |
---|---|
UPDATE | Update the document to remove the associated attachment token. |
EVICT | Delete the entire document, including the associated attachment token, from the Ditto store. |
Type | Blob Store Location |
---|---|
Ditto Edge SDK | - If running in the browser or a server-based system, in-memory storage. Specifically, within Random Access Memory (RAM). - If running on a mobile device like an iPhone, filesystem storage. |
Ditto Server | Cloud object storage service: Amazon WebServices (AWS) Simple Storage Service (S3). |