Stream large file via HTTP

Hello all,
my goal is to stream a large file via a HTTP GET request to a client. The file is potentially larger than my server’s memory. Related to that, I found the following on Stack Overflow: stream - Send a large file with HTTP.jl - Stack Overflow

function testfun(req::HTTP.Request)
    data = Mmap.mmap(open("testfile.txt"), Array{UInt8,1})
    return HTTP.Response(200,data)
end

The file transfer (resp. download) works with that solution, but Julia still loads the whole file into memory. Is there a way in Julia / HTTP.jl to feed the file to the HTTP response as stream without loading the whole file into memory?

Thank you!

3 Likes