toByteArray

abstract suspend fun toByteArray(coroutineScope: CoroutineScope? = null, expectedSize: Long? = null, maxSize: Long? = null): ByteArray?

Creates a ByteArray and stores it into a cache for re-use.

Return

The loaded media as a ByteArray or null when maxSize was exceeded.

Parameters

coroutineScope

The CoroutineScope is used to remove the ByteArray from cache when not used anymore. Otherwise, it is automatically removed after the media value defined in MatrixClientConfiguration.cacheExpireDurations.

expectedSize

The size of the media propagated by e.g., events or null if not known.

maxSize

The max size allowed loading into memory.