PrivMX DOCS
API Reference/PrivMX Endpoint Java Extra/Inbox

InboxEntryStream

Provides a streamlined process for creating and sending Inbox entries with optional file attachments. This class simplifies interacting with the Inbox API for sending entries, especially when dealing with multiple files. It manages the lifecycle of the entry creation process, including file uploads and final entry submission.

Static Methods

prepareEntry

Creates InboxEntryStream instance ready for streaming. This method initializes an InboxEntryStream and prepares it for sending an entry with the provided data. It creates an Inbox handle and sets the initial state of the stream to State#FILES_SENT.

Params

inboxApi

InboxApi

reference to Inbox API

inboxId

String

ID of the Inbox

entryStreamListener

EntryStreamListener

the listener for stream state changes

data

byte[]

entry data to send

public static InboxEntryStream prepareEntry(
InboxApi inboxApi,
String inboxId,
EntryStreamListener entryStreamListener,
byte[] data
)

Returns

InboxEntryStream · instance of InboxEntryStream prepared for streaming

prepareEntry

Creates InboxEntryStream instance ready for streaming. This method initializes an InboxEntryStream and prepares it for sending an entry with the associated files and empty data. It creates Inbox and file handles, setting the initial state of the stream to State#PREPARED, indicating readiness for file transfer.

Params

inboxApi

InboxApi

reference to Inbox API

inboxId

String

ID of the Inbox

entryStreamListener

EntryStreamListener

the listener for stream state changes

fileInfos

List<FileInfo>

information about each entry's file to send

public static InboxEntryStream prepareEntry(
InboxApi inboxApi,
String inboxId,
EntryStreamListener entryStreamListener,
List<FileInfo> fileInfos
)

Returns

InboxEntryStream · instance of InboxEntryStream prepared for streaming

prepareEntry

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 and optional associated files. It creates Inbox and file handles (if fileInfos is provided), setting the initial state of the stream to State#PREPARED, indicating readiness for data and file transfer.

Params

inboxApi

InboxApi

reference to Inbox API

inboxId

String

ID of the Inbox

entryStreamListener

EntryStreamListener

the listener for stream state changes

data

byte[]

entry data to send

fileInfos

List<FileInfo>

information about each entry's file to send

public static InboxEntryStream prepareEntry(
InboxApi inboxApi,
String inboxId,
EntryStreamListener entryStreamListener,
byte[] data,
List<FileInfo> fileInfos
)

Returns

InboxEntryStream · instance of InboxEntryStream prepared for streaming

prepareEntry

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.

Params

inboxApi

InboxApi

reference to Inbox API

inboxId

String

ID of the Inbox

entryStreamListener

EntryStreamListener

the listener for stream state changes

data

byte[]

entry data to send

fileInfos

List<FileInfo>

information about each entry's file to send

userPrivKey

String

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

public static InboxEntryStream prepareEntry(
InboxApi inboxApi,
String inboxId,
EntryStreamListener entryStreamListener,
byte[] data,
List<FileInfo> fileInfos,
String userPrivKey
)

Returns

InboxEntryStream · instance of InboxEntryStream prepared for streaming

Methods

cancel

Cancels the stream and sets its state to State#ABORTED. If the stream is currently sending files, all pending file operations will be canceled. If the stream is in the process of sending the entry, this operation will not have any effect.

public void cancel()

sendEntry

Sends the entry data and closes this stream, transitioning it to the State#SENT state. This method should only be called after all files associated with the entry have been successfully sent, indicated by the stream being in the State#FILES_SENT state.

public synchronized void sendEntry()

sendFiles

Initiates the process of sending files using the provided executor. This method submits each file for sending to the fileStreamExecutor and wait for completion.

Params

fileStreamExecutor

ExecutorService

the executor service responsible for executing file sending tasks

public synchronized void sendFiles(
ExecutorService fileStreamExecutor
)

sendFiles

Sends files using a single-threaded executor (see: Executors#newSingleThreadExecutor).

public void sendFiles()

We use cookies on our website. We use them to ensure the proper functioning of the site and, if you agree, for purposes we set, such as analytics or marketing.