Vijikumar M
Vijikumar M

Reputation: 3764

Rails Paperclip : Is there any option to save the uploaded file outside of the public folder?

I am using paperclip gem for uploading. And i want to save the uploaded file/image outside of the public folder. If you have any idea please share.

Upvotes: 1

Views: 955

Answers (1)

Martin
Martin

Reputation: 7723

Actually there is many. The 'public' option is just to be able to test easily. For your production server, paperclip gives three options:

  • File Storage
  • S3 Storage (via aws-sdk)
  • Fog Storage

File storage can be configured to go to any folder you want with something like:

config.paperclip_defaults = {    
  :path => "/yourfolder/:basename.:extension"
}

This can be overridden on the class itself if needed:

has_attached_file :avatar, 
  :path => "/yourotherfolder/:basename.:extension"

Upvotes: 2

Related Questions