fetchAttachment

fun fetchAttachment(token: DittoAttachmentToken, onFetchEvent: (DittoAttachmentFetchEvent) -> Unit): DittoAttachmentFetcher

Trigger an attachment to be downloaded locally to the device and observe its progress as it does so.

When you encounter a document that contains an attachment the attachment will not automatically be downloaded along with the document. You trigger an attachment to be downloaded locally to a device by calling this method. It will report changes to the status of the fetch attempt as it tries to download it. Assuming it succeeds in downloading the attachment it will call the onFetchEvent block with a completed event object, which will hold a reference to the attachment.

Return

a DittoAttachmentFetcher object, which must be kept alive for the fetch request to proceed and for you to be notified about the attachment's fetch attempt events.

Parameters

token

the DittoAttachmentToken relevant to the attachment that you wish to download and observe.

onFetchEvent

a closure that will be called when there is an update relating to the attachment fetch attempt.


fun fetchAttachment(token: DittoAttachmentToken, fetchEventHandler: DittoAttachmentFetchEventHandler): DittoAttachmentFetcher

Trigger an attachment to be downloaded locally to the device and observe its progress as it does so.

When you encounter a document that contains an attachment the attachment will not automatically be downloaded along with the document. You trigger an attachment to be downloaded locally to a device by calling this method. It will report changes to the status of the fetch attempt as it tries to download it. Assuming it succeeds in downloading the attachment it will call the fetchEventHandler with a completed event object, which will hold a reference to the attachment.

Return

a DittoAttachmentFetcher object, which must be kept alive for the fetch request to proceed and for you to be notified about the attachment's fetch attempt events.

Parameters

token

the DittoAttachmentToken relevant to the attachment that you wish to download and observe.

fetchEventHandler

an object that implements DittoAttachmentFetchEventHandler, whose onFetchEvent function gets called with a DittoAttachmentFetchEvent object when there is an update relating to the attachment fetch attempt.