Class DittoAttachmentFetcher

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

public final class DittoAttachmentFetcher extends Object implements Closeable

Manages the fetching of an attachment from remote peers.

These objects are returned by calls to DittoStore.fetchAttachment(DittoAttachmentToken). The fetcher handles downloading attachment data from remote peers in the mesh network.

This class implements Closeable, so it can be used with try-with-resources to ensure proper cleanup:

`try (DittoAttachmentFetcher fetcher = store.fetchAttachment(token, event ->{// Handle fetch events})){// Attachment fetch is in progress}// Fetcher is automatically closed and cleaned up`
  • Method Details

    • close

      public void close() throws IOException

      Stops fetching the associated attachment and cleans up any associated resources.

      This should be called once you have completed an attachment fetch operation or before an attachment fetch has completed if you want to cancel the fetch operation.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException - if an I/O error occurs during cleanup.
    • 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