Image_tag and files outsite /public directory

I have some image files under

/app
/uploads
/images/
111.jpg

/public
/images

.
.

How can I user image_tag to display the images under
/uploads/images/…?

Any hints?


Jochen K.
gissmoh.de, figgfrosch.de, ror-ror.de

jochen kaechelin wrote:

.
.

How can I user image_tag to display the images under
/uploads/images/…?

Any hints?

Hi Jochen,
you can create symlink in public dir that would point to uploads.


Bojan M.
→ Ruby on Rails and Web D. Blog : http://source.mihelac.org

Bojan M. schrieb:

Hi Jochen,
you can create symlink in public dir that would point to uploads.But

But the files must be protected…when I create a syslink everyone
is able to access them! Right?


Jochen K.
gissmoh.de, figgfrosch.de, ror-ror.de

Adam C. schrieb:

protected from what? In what cases do you want users to be able to
view these images?

Only logged in users are able to view the files.

When I store the images under /public/images/111.jpg
everyone is able to view the images.

But I thing I got a soultion:

send_file RAILS_ROOT +
“/downloads/#{params[:galery_id]}/#{params[:filename]}”, :type =>
“image/jpeg”, :disposition => ‘inline’

         111.jpg


Jochen K.
gissmoh.de, figgfrosch.de, ror-ror.de


Jochen K.
gissmoh.de, figgfrosch.de, ror-ror.de

protected from what? In what cases do you want users to be able to
view these images?

Adam

jochen kaechelin wrote:

But I thing I got a soultion:

send_file RAILS_ROOT +
“/downloads/#{params[:galery_id]}/#{params[:filename]}”, :type =>
“image/jpeg”, :disposition => ‘inline’

beware that send_file keep files in memory until they are downloaded, so
that means you could get in trouble with big files or many downloads at
time.

Bojan

You can also use the X-Sendfile header to send non-publicly accessible
files through the web server (providing that it supports this header),
without tying up your rails process. You can read more about it here:

http://john.guen.in/past/2007/4/17/send_files_faster_with_xsendfile/

Adam

The following may be of use to you:

Adam C. wrote:

You can also use the X-Sendfile header to send non-publicly accessible
files through the web server (providing that it supports this header),
without tying up your rails process. You can read more about it here:

http://john.guen.in/past/2007/4/17/send_files_faster_with_xsendfile/
http://blog.lighttpd.net/articles/2006/07/22/mod_proxy_core-got-x-sendfile-support

Adam

or create own x-send_file method that would create symlink with unique
name and redirect logged user to it. Clear can be done with cronjob.


Bojan M.
→ Ruby on Rails and Web D. Blog : http://source.mihelac.org