views:

22

answers:

2

Hi,

I wand to give a preview of the just uploaded pictures. These pictures are not saved in the public folder, as they are not public...

How can I do this?

Thanks Markus

+1  A: 

You could:

1) Create symlink to the images in the public folder?

2) As you are using the images publicly, they should really be in the public folder - why are they currently not?

aaronmase
no they are not public! the only get showed to the user who upload the image... thanks for your answer, I will prove the symlink hint!
Markus
I think the answer with the controller is probably the best approach
aaronmase
+2  A: 

You need create a Controller to send_file ( http://api.rubyonrails.org/classes/ActionController/Streaming.html#method-i-send_file ) it.

class AvatarsController

  def show
    send_file my_avatar_path, :type => 'image/jpeg', :disposition => 'inline'
  end
end

In this controller you can add all authorization you want.

shingara
Hi Shingara, Thanks for your answer! I'll try it now!
Markus
I tried it but unfortunately there doesn't get any data loaded:
Markus
send_file path, :type => 'image/jpeg', :disposition => 'inline' (I made sure that the path is wright!)
Markus
It works now as I use send_data instead... strange! does anybody know why?
Markus