Reputation: 70819
I have a base64-encoded JPG in my app, and I'd like to render that image as a JPG in a controller.
Upvotes: 5
Views: 4731
Reputation: 10405
Here's how to do it with the usual render
syntax:
render text: Base64.decode64(your_base_64_string),
content_type: 'image/jpeg'
Upvotes: 4
Reputation: 70819
I worked this out as soon as I asked the question. Assuming you have the base64 string in @image_data
:
send_data Base64.decode64(@image_data),
:type => 'image/jpeg', :disposition => 'inline'
Upvotes: 7