Sunday, June 6, 2010

[Rails] Re: net/http set content-type for images

I am asking how to turn the JPEG IO stream into an image I can pass on
and display in a view.

So I have

def index
result = Net::HTTP.get_response(URI.parse('http://
link_to_image.jpg') )
...
@image = ??

end

index.html.erb
@image = pretty picture


On Jun 6, 6:37 pm, Hassan Schroeder <hassan.schroe...@gmail.com>
wrote:
> On Sun, Jun 6, 2010 at 5:40 PM, Kim <kim.gri...@gmail.com> wrote:
> > I need to pull an image from a URL (I have permission) that is a .jpg.
> >  result = Net::HTTP.get_response(URI.parse('http://
> > link_to_image.jpg') )
>
> > result.body => gives me encoded junk.
>
> No, it gives you what you asked for: a JPEG-format IO stream.
>
> Are you saving it, or passing it to some other process, or what?
>
> > so I can display the image.
>
> Or in other words, "display" it how?
>
> --
> Hassan Schroeder ------------------------ hassan.schroe...@gmail.com
> twitter: @hassan

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate