Use send_file in built-in image handler

This commit is contained in:
Sdogruyol 2016-07-19 21:01:49 +03:00
parent 5e297d86f8
commit 676ed2aa67

View file

@ -35,11 +35,7 @@ module Kemal
image = env.params.url["image"]
file_path = File.expand_path("libs/kemal/images/#{image}", Dir.current)
if File.exists? file_path
env.response.headers.add "Content-Type", "application/octet-stream"
env.response.content_length = File.size(file_path)
File.open(file_path) do |file|
IO.copy(file, env.response)
end
send_file env, file_path
end
end