Ditto JS SDK v5.0.0
    Preparing search index...

    Class Attachment

    Represents an attachment and can be used to insert the associated attachment into a document at a specific key-path. You can't instantiate an attachment directly, please use the ditto.store.newAttachment() method instead.

    Index

    Accessors

    Methods

    Accessors

    • get id(): string

      The attachment's ID.

      Returns string

    • get len(): number | bigint

      The attachment's size given as number of bytes.

      Returns number | bigint

    • get metadata(): { [key: string]: string }

      The attachment's metadata.

      Returns { [key: string]: string }

    Methods

    • Copies the attachment to the specified file path.

      React Native:

      • Relative paths (e.g., "data/file.txt") are automatically prefixed with ditto.absolutePersistenceDirectory, resulting in ${persistenceDir}/data/file.txt
      • Absolute paths (e.g., "/Users/me/file.txt") are used as-is without modification

      Node.js:

      • Relative paths are resolved relative to the current working directory

      This method throws an error when running in the browser.

      Parameters

      • path: string

        The path where the attachment should be copied.

      Returns Promise<void>

    • Returns the attachment's data.

      Returns Promise<Uint8Array<ArrayBufferLike>>