Class DittoAttachment

java.lang.Object
com.ditto.java.DittoAttachment
All Implemented Interfaces:
Closeable, AutoCloseable

public final class DittoAttachment extends Object implements Closeable
Represents an attachment and can be used to insert the associated attachment into a document at a specific key.
  • Method Details

    • getId

      public @NonNull String getId()
      Returns the attachment's ID.
      Returns:
      the attachment's unique identifier.
    • getLength

      public @NonNull DittoULong getLength()
      Returns the length (size) of the attachment.
      Returns:
      the attachment's length in bytes.
    • getMetadata

      public @NonNull DittoCborSerializable.Dictionary getMetadata()
      Returns the attachment's metadata.
      Returns:
      a DittoCborSerializable.Dictionary containing the attachment's metadata.
    • getData

      public byte[] getData()
      Returns the attachment's data as a ByteArray.
      Returns:
      the attachment's data.
    • getInputStream

      public @NonNull FileInputStream getInputStream()
      Returns an input stream for the attachment file.
      Returns:
      an input stream for the attachment file.
    • copyToPath

      public void copyToPath(@NonNull String path) throws DittoException
      Copies the attachment to the specified file path.
      Parameters:
      path - the path that the attachment should be copied to.
      Throws:
      DittoException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object