I need to pull an image from a URL (I have permission) that is a .jpg.
I know I need to set the content-type to 'image/jpeg', but not sure
where to do that at.
result = Net::HTTP.get_response(URI.parse('http://
link_to_image.jpg') )
result.body => gives me encoded junk.
Looking for help on how to set the content-type so I can display the
image.
Really? Do you really think there isn't a reason why I am not just
using an image_tag? Really?
Seems like a legitimate question to me.
The image is protected and I have been given access to pull it from my
web server to use in my app.
Looking for help in answering my original post please. Thanks.
All an image is is a stream of bytes, which you have already got.
Furthermore the image is fetched by a separate request. If you really
need to go down this route you should probably craft the <img> tag to
point at a particular controller/action in your app and from that
action make your http request and return the bytes you get. You might
also want to cache the image on your server.
Or perhaps some rewrite rules to proxy those requests to the origin
server might make more sense