【发布时间】:2019-12-20 21:58:15
【问题描述】:
我正在使用改造客户端下载文件,但是当有大文件(200 MB)时,它会抛出java.lang.OutOfMemoryError:
我也有@Streaming 注释,这是我的下载服务方法
@Streaming
@GET("{path}")
suspend fun downloadFile(@Path("path") path: String): Response<ResponseBody>`
这里是调用代码sn-p
suspend fun downloadFile(remotePath: String): FileDownloadResponse {
try {
val response = api.downloadFile(remotePath)
if (response.isSuccessful) {
FileDownloadResponse.Success(response.body()!!)
} else {
FileDownloadResponse.Fail()
}
} catch (e: Exception) {
e.printStakTrace()
FileDownloadResponse.Fail(throwable = e)
}
}
val response = remoteRepositroy.downloadFile(remotePath)
val writeResult = response.body.writeResponseBodyToDisk()
改装版 = 2.6.0
协程版本 = 1.3.0-M1
【问题讨论】:
标签: java android kotlin retrofit kotlin-coroutines