ktor-io / io.ktor.utils.io / copyTo

copyTo

suspend fun ByteChannelSequentialBase.copyTo(dst: ByteChannelSequentialBase, limit: Long = Long.MAX_VALUE): Long
Deprecated: This is going to become internal. Use ByteReadChannel receiver instead.

suspend fun ByteReadChannel.copyTo(dst: ByteWriteChannel): Long

Reads bytes from receiver channel and writes them to dst channel. Closes dst channel if fails to read or write with cause exception.

Return
a number of copied bytes

suspend expect fun ByteReadChannel.copyTo(dst: ByteWriteChannel, limit: Long): Long

Reads up to limit bytes from receiver channel and writes them to dst channel. Closes dst channel if fails to read or write with cause exception.

Return
a number of copied bytes