RE: Showing Images from a file store

Hi,
Thanks a lot for the response. If you can post a working example, that
would be great.
Really appreciate it.
Thanks
Silvy Mathews

Here’s a [very] rough, but working example for a PDF…

Controller:

class FileGrabberController < ApplicationController
@@path = ‘your/path’
def get_file
send_file @@path + ‘a.pdf’, :type => ‘application/pdf’
end
end

View:

pdf

I know there’s an inline option as well, i.e. for a JPG

:disposition => ‘inline’

or something like that - hope that helps…

brez

Hi John,
That really worked. I did not knew that we could specify a controller
name
and the method name inside the view. Thanks a lot. Really appreciate
that.

Thanks
Silvy

That really worked.

good to hear…

I did not knew that we could specify a controller
name
and the method name inside the view.

well what youre really specifying is a URL that is interpreted as that
method on that controller, i.e. the rails convention for URL mapping.
The browser then retrieves the img like a typical JPG. send_file returns
a byte stream [i.e. no HTTP headers, etc] which is subsequently
rendered… It all pretty straightforward actually - it’s probably worth
reading abt the HTTP 1.1 protocol if you found the previous few lines
compelling…

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs