I'm downloading files using retrofit client, but when there is large file (200 MB) it throws java.lang.OutOfMemoryError:
I have @Streaming
annotation also and this is my download service method
@Streaming
@GET("{path}")
suspend fun downloadFile(@Path("path") path: String): Response<ResponseBody>`
Here is invoke code snippet
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()
Retrofit version = 2.6.0
Coroutine version = 1.3.0-M1