dave08
05/10/2018, 12:26 PMrecieveFile
in response object...)?Deactivated User
05/10/2018, 12:36 PMreceive<ByteReadChannel>
and copy it to a file. https://ktor.io/clients/http-client.html#HttpResponse
Let me check if there is an example for thatsuspend fun downloadFile(dstFile: File, url: String, method: HttpMethod = HttpMethod.Get) {
HttpClient(Apache.config { followRedirects = true }).call {
this.method = method
url(url)
}.receiveToFile(dstFile)
}
suspend fun HttpClientCall.receiveToFile(file: File) = response.content.copyAndClose(file.writeChannel())
Does this work for you?dave08
05/10/2018, 1:38 PM