Reputation: 4896
I am not using Rails, so the send_data
function will not work, unfortunately.
image = User.select("image, image_mime").where("username = '#{params[:name]}'").first
send_data( image.image,
:type => image.image_mime,
:disposition => 'inline')
Upvotes: 0
Views: 758
Reputation: 44080
Check out the source of send_file
method:
def send_file(filename, content_type = nil, content_disposition = nil)
content_type ||= Rack::Mime.mime_type(::File.extname(filename))
content_disposition ||= File.basename(filename)
response.body = ::File.open(filename, 'rb')
response['Content-Length'] = ::File.size(filename).to_s
response['Content-Type'] = content_type
response['Content-Disposition'] = content_disposition
response.status = 200
throw(:respond, response)
end
You can try doing the same, only set the body to image.image
instead of reading it from a file.
Upvotes: 2