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 kaechelin wrote:

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?

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

Bojan Mihelac schrieb:

jochen kaechelin wrote:

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?

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?

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

Adam

Adam Cohen 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'

jochen kaechelin wrote:

Adam Cohen 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'

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/
http://blog.lighttpd.net/articles/2006/07/22/mod_proxy_core-got-x-sendfile-support

Adam

The following may be of use to you:

http://blog.lighttpd.net/articles/2006/07/22/mod_proxy_core-got-x-sendfile-support

Adam Cohen 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.