upload

fun upload(name: String, data: ByteArray, windowCapacity: Int = 1, memoryAlignment: Int = 1): Flow<TransferState<Unit>>

Uploads a file to the device.

The upload starts when the flow is collected, and is cancelled when the collection is. The upload may be paused, resumed and cancelled using the controller from TransferState.Started.

Parameters

name

The path of the file on the device.

data

The data of the file.

windowCapacity

The number of packets sent without waiting for the response. Use 1 if the device does not support the window upload.

memoryAlignment

The alignment of the packets, used when the window capacity is 2 or more. Each packet is trimmed to a size that is a multiple of this value.

Throws

if the upload fails.


fun upload(name: String, data: InputStream, totalBytes: Int): Flow<TransferState<Unit>>

Uploads a file to the device, reading it from the given stream.

The upload starts when the flow is collected, and is cancelled when the collection is. The stream is not closed.

Parameters

name

The path of the file on the device.

data

The stream to read the file from.

totalBytes

The number of bytes to read from the stream.

Throws

if the upload fails.