https://kotlinlang.org logo
#android
Title
# android
h

Hugh Edwards

02/22/2023, 1:18 AM
Hey this isn’t necessarily an android question but could someone please verify: I’m currently downloading and unzipping a file on android. It’s around ~1gb of files, but it all happens extremely slowly currently The current code I have does this: I launch an async on
<http://dispatchers.IO|dispatchers.IO>
In here I start an HttpUrlConnection & call openConnection() on it I await this connection in a coroutine under
dispatchers.default
where i then do
Copy code
val inputStream = connectionJob.await()
processZipFile(inputStream.inputStream)
inputStream.disconnect()
and in processZipFile i create a zip entry stream from the IS, iterate through each entry, creating a buffered output stream per file (4096 buffer size to read) before closing it all Is this doing the download on the wrong dispatcher due to the await placement? Also is this keeping the connection open while unzipping as opposed to getting the whole thing in memory before processing it? Looking for any suggestions and improvements, thanks
It does seem like even just the downloading of the zip outside of any application context is very slow Downloading from a local network via chrome and it’s only downloading at approx 1MB/sec
3 Views