Paperclipped on Heroku?
Asked Answered
D

5

11

I was curious if anyone could get paperclipped working on Heroku without using S3. I'm assuming Heroku is a read-only system, but there must be some way to save images there.

Discountenance answered 23/2, 2011 at 20:19 Comment(1)
you can store links in the database and hotlink to flickr if it's just imagesNuzzle
C
19

You can't write to Heroku's file system, so no, there is no way to save images the way you want. Your options are using a service like S3, or storing them in the database. I recommend using S3, because databases are not optimized for file storage. It's worth reading Heroku's documentation on file uploads.

Cloddish answered 23/2, 2011 at 20:27 Comment(2)
Is there a deposit for S3, or is really only fractions of a cent. Considering I'm looking at uploading only a few images every couple months, would I only be paying close to a dollar or two?Discountenance
You'll pay less than a dollar (depending on traffic) if it's only a few images every couple of months. S3 is cheap.Cloddish
R
12

You may save images to the log and tmp directories.

However, that's a horrible, horrible idea.

  • If you git push heroku, your application will be deployed to a new dyno. The new dyno will not have the images, and the images will be forever gone.

  • If you have two dynos, and one dyno saves the image, the image will not be available to the next dyno.

So, effectively, there is no good way to save images to the filesystem.

If you want, you can write your own an adapter for Paperclip that will store images in the database.

But really, you should store images in S3 when you use Paperclip on Heroku, because it's the easy default way to do it.

Resentful answered 23/2, 2011 at 20:29 Comment(0)
A
3

As an aside, this is also the same reason why SASS requires a plugin on Heroku, limited access to disk. I use Paperclip in a number of apps on Heroku, as others have said, S3 hands down is the way to go.

Allista answered 24/2, 2011 at 5:6 Comment(0)
H
3

This is for someone like me who doesn't own a credit card and still wants to get this to work as you need to provide credit card credentials to use S3. Cloudinary Gem here allows Rails models managed via Paperclip to store image and file assets on a Cloudinary instance. I only had to add the yaml file to my config directory and specify the storage, path in my model as follows.

has_attached_file :image,
  :storage => :cloudinary,
  :path => ':id/:style/:filename'

Refer the above link for more details.

Hairy answered 16/5, 2017 at 15:16 Comment(0)
B
-1

Maybe Amazon EBS can be used with Heroku -- or is it too low level?

Boresome answered 23/2, 2011 at 20:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.