Quy D X Nguyen
05/27/2020, 6:05 PMe5l
05/28/2020, 1:16 PMQuy D X Nguyen
05/28/2020, 3:21 PMget("/") {
call.respondBytesWriter(ContentType.defaultForFileExtension(".jpg")) {
client.get<HttpStatement>("<https://chandra.harvard.edu/photo/2017/arp299/arp299_4k.jpg>").execute { response: HttpResponse ->
//response.receive<ByteReadChannel>().joinTo(this, false)
val (channelResponse, channelFile) = response.receive<ByteReadChannel>().split(this@embeddedServer)
channelFile.joinTo(File("image").writeChannel(), true)
channelResponse.joinTo(this, false)
}
}
}
e5l
05/28/2020, 3:23 PMlaunch { }
? The channels should be consumed simultaneously.Quy D X Nguyen
05/28/2020, 3:37 PMlaunch{}
call<http://Dispatchers.IO|Dispatchers.IO>
context for writeChannel()
does not play well with split()
. Do you know why?
val fileSave = newFixedThreadPoolContext(8, "fileSave")
...
channelFile.joinTo(File("image").writeChannel(fileSave), true)
split()
gums everything up, but they work individually