prepareEntry

fun prepareEntry(inboxApi: InboxApi, inboxId: String, entryStreamListener: InboxEntryStream.EntryStreamListener, data: ByteArray = ByteArray(0), fileInfos: List<InboxEntryStream.FileInfo> = emptyList(), userPrivKey: String? = null): InboxEntryStream

Creates an InboxEntryStream instance ready for streaming, with optional files and encryption.

This method initializes an InboxEntryStream and prepares it for sending an entry with the provided data, optional associated files, and optional encryption using the sender's private key. It creates an Inbox handle and initializes file handles for any associated files. The initial state of the stream is determined based on the presence of files: if no files are provided, the state is set to State.FILES_SENT. Otherwise, it's set to State.PREPARED, indicating readiness for file transfer.

Return

instance of InboxEntryStream prepared for streaming

Parameters

inboxApi

reference to Inbox API

inboxId

ID of the Inbox

entryStreamListener

the listener for stream state changes

data

entry data to send

fileInfos

information about each entry's file to send

userPrivKey

sender's private key which can be used later to encrypt data for that sender

Throws

when method encounters an exception while creating handles for Inbox or file

when method encounters an unknown exception while creating handles for Inbox or file

when IllegalStateException was thrown while creating handles for Inbox or file