我使用带有akka后端的sttp lib从服务器加载文件。以下任何一种方法都会导致加载 1Gb 文件时占用大量内存:
import com.softwaremill.sttp._
val file: File = new File(...)
sttp.response(asStream[Source[ByteString, Any]])
.mapResponse { src =>
src.runWith(FileIO.toPath(file.toPath, options, 0))
}
sttp.response(asFile(file, false))
是否有机会在写入后立即将数据写入块并从内存中逐出块?