Topic: acts_as_attachment storing photos outside of public folder.

hi,
i am creating a little photo gallery app  and would like users to be able to store their photos and give them the ability to either make certain photos public for all, or only available to their friends.  therfore, i thought it would be best to store all user photos outside the public folder and before i fetch them for a view, check if that certain photo iss checked private or not.

now at first i did a basic store, but for some reason, ti am gettting  an error. must i define a route to be able to render a photo to a view?

Re: acts_as_attachment storing photos outside of public folder.

after some more research, it appears to be a bit difficult.

since i want to grant access to friends and render a gallery page of img tags that link to protected files ....is unknown to me.

send file works for sending 1 file for download. also i found that send file can also send 1 img tag....but not sure if it can send a list....

phew...im tired.

Re: acts_as_attachment storing photos outside of public folder.

can someone help me out with this. i found something

http://mcubed.name/blog/articles/read/9

Controller:
def protected_image
  @image_id = get_image_id
end
def generate_image
  image_data_str = read_image_data
  send_data( image_data_str, :type =>

Re: acts_as_attachment storing photos outside of public folder.

image_data_str = UserPhoto.find(15)

image_data_str will contain the model, not the img data...

check out:
http://api.rubyonrails.com/classes/Acti … aming.html

Looks like you should be able to do something like...

@user_photo = UserPhoto.find(15)

send_file @user_photo.image, :type => 'image/jpeg', :disposition => 'inline'


Will probably need some tweaking.. but that should be a starting point

Re: acts_as_attachment storing photos outside of public folder.

thanks timmaah, got it working....


do you know how i can setup filepath in aaa  to  put folders under a users name?


  acts_as_attachment :storage => :file_system, :file_system_path => 'public/:user', :thumbnails => {:thumb => '144x110'}