Dumitru Preguza
02/22/2026, 4:02 PMAlexander Sysoev
02/23/2026, 9:45 AMDumitru Preguza
02/23/2026, 10:36 AMAlexander Sysoev
02/23/2026, 6:33 PMJoost Klitsie
02/25/2026, 8:03 AMJoost Klitsie
02/25/2026, 8:06 AMJoost Klitsie
02/25/2026, 8:08 AMAlexander Sysoev
02/25/2026, 8:09 AMAlexander Sysoev
02/25/2026, 8:09 AMJoost Klitsie
02/25/2026, 8:17 AMbytes = byteArray.asFlow(CHUNK_SIZE)
fun ByteArray.asFlow(chunkSize: Int): Flow<ByteArray> {
var count = 0
return (0 until size step chunkSize).asFlow().map { startIndex ->
count++
val endIndex = minOf(startIndex + chunkSize, size)
this.copyOfRange(startIndex, endIndex)
}
}
const val CHUNK_SIZE = 64 * 1024 // 64KB
// Inside RpcClient
suspend fun uploadImage(
authentication: SignedAuthentication,
fileName: String,
bytes: Flow<ByteArray>,
): PQResult<MediaRecord, CommonError>
rpcClient.uploadImage(
authentication = authentication,
fileName = fileName,
bytes = bytes
.onEach { delay(100) },
)