I have implemented sparkjava framework on Android for embedded web server to serve files from android device, and it is able to list files on web page, but the issue is when downloading file from android device using web interface unable to download files with file size greater than 70-80 MB.
Android app(sender, host, server) running embedded http webserver using sparkjava and receiving side is desktop web browser connected to mobile hotspot which is running android app.
If file size is more than 70-80 MB Android Studio log show 'Out of Memory'
Image of webpage listing files from android device and here Android studio log
Using below kotlin code to provide downloadable file to web browser(the downloadable file is from android device)
httpService.get("/download/:file") { req, res ->
val fileParam = decode(req.params(":file"))
val filePath = Paths.get(fileParam)
val bytes: ByteArray = Files.readAllBytes(filePath)
val raw: HttpServletResponse = res.raw()
raw.outputStream.write(bytes)
raw.outputStream.flush()
raw.outputStream.close()
res.raw
}
The above code is in Android app.
How to solve this issue?