Hey Hippo Man,
There are all kinds of different scenarios in which you might need to return a file, and each scenario has it's own set of suitable solutions. Scorched therefore doesn't offer a send file helper, as to it properly, you'd have to re-invent the wheel (i.e R)
For a file on the file system, in most cases you would want your web server to serve them natively (e.g, Nginx, Apache) as they'll always do a better job in terms of both performance and supporting the full HTTP feature set. You would typically redirect the user to the appropriate URL in that case.
For dynamic data, such as serving a file or image from a database, you'd probably be best to create your own little application-specific `send_file` helper. A basic example would be as follows:
def send_file(filename, data)
response.headers['Content-Disposition'] = "attachment; filename=\"#{filename}\""
response.headers['Content-Length'] = data.bytesize.to_s
halt data
end
This is normally an adequate solution for smaller files. For larger files, you'd likely want something that supports the Content-Range headers to allow pause/resume of downloads, which something like Rack::File supports.
Cheers,
Tom