writeAttachmentToShareableFile

suspend fun writeAttachmentToShareableFile(context: Context, attachment: Attachment, chatClient: () -> ChatClient = { ChatClient.instance() }): Result<Uri>

Writes an attachment to a shareable file in the cache directory and returns a shareable URI. If the attachment is already cached, returns the cached file URI immediately. Otherwise, downloads the attachment from the server and caches it.

Return

A Result containing the Uri of the shareable file, or an error if the operation fails.

Parameters

context

The Android context.

attachment

The attachment to write.

chatClient

Lambda providing the ChatClient instance for downloading. Defaults to ChatClient.instance.