Avoid going to String first when gzipping
Is there a way of doing this gzip without first going to String and then back to ByteArray?
suspend fun gzip(content: ByteArray): ByteArray = withContext(
Dispatchers.IO) {
ByteArrayOutputStream().apply {
GZIPOutputStream(this).writer(UTF_8).use { it.write(String(content)) }
}.toByteArray()
}
suspend fun ungzip(content: ByteArray): ByteArray = withContext(
Dispatchers.IO) {
GZIPInputStream(content.inputStream()).bufferedReader(UTF_8).use { it.readText() }.toByteArray()
}...