Reputation: 14740
So I'm making a Rails app which allows Users to create Items, and each Item has an image attachment, which is handled through the Paperclip gem. The Paperclip gem, by default, saves photos to the public folder, both in original (and thumbnail) form.
I can see how this can get out of hand pretty fast in terms of storage space, given that photos can be fairly big.
My questions:
1) How much space will Heroku allow me to hold for images in the public folder?
2) If Heroku only allows you to hold a finite amount of data in this folder (which I'm sure it does), how can I handle photo storage for a site that will probably have a lot of images? Remotely perhaps? Compression? (Specifics would be nice, as I am completely new to image storage.)
Upvotes: 1
Views: 1793
Reputation: 6415
As Chris said, you'll want to use a third party service like S3 and if you do end up using Paperclip then you'll eventually have something like this example in your model.
has_attached_file :photo,
:styles => { :thumb=> "100x100", :small => "300x300" },
:storage => :s3,
:s3_credentials => "#{Rails.root.to_s}/config/s3.yml",
:path => "/:id/:style/:filename"
And in your config directory you'll have an s3.yml credentials file that would look like:
development:
bucket: blahblah
access_key_id: sfoi40j8elkfv08hwo
secret_access_key: DJyWuRtsfoi40j8elkfv08hwos0m8qt
production:
bucket: blahblah
access_key_id: sfoi40j8elkfv08hwo
secret_access_key: DJyWusfoi40j8elkfv08hwos0m8qt
Upvotes: 0
Reputation: 11628
Heroku has a read-only file system for your app. Use Amazon S3 to store your uploaded images. Paperclip has great support for S3. Check out this Heroku guide.
Upvotes: 3