Kevin Brown
Kevin Brown

Reputation: 12650

Heroku File Storage

Heroku only has 100MB of file storage, right? I'm making a low-level rails app and I really like Heroku, but if my app allows each user to upload one picture, I may run out of space quickly...is there a simple solution that will allow me to have alternative file storage for profile pics or something of the like?

Upvotes: 48

Views: 60843

Answers (3)

Baraja Swargiary
Baraja Swargiary

Reputation: 459

Yes, the simplest solution is to use the api.imgur.com, which allows you to upload 1250 images for free per hour.

You just need to register and get your client id then you need to send post request to

https://api.imgur.com/3/upload

with the image data as form data. Then you get a link of the uploaded image in response data which you can store it in database and then you can access the image like any other image with the link from front end.

more here:

Imgur API docs link

Upvotes: 2

Sam 山
Sam 山

Reputation: 42863

See this blog post

In your model.

has_attached_file :picture, 
                   :styles => {:large => "275x450>"},
                   :storage => :s3, 
                   :s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
                   :path => "appname/:attachment/:style/:id.:extension"

In s3.yml in your config dir:

    development:
      bucket: bucketname
      access_key_id: key
      secret_access_key: key

    production:
      bucket: bucketname
      access_key_id: key
      secret_access_key: key

Then go signup for a bucket at Amazon S3: http://aws.amazon.com/s3/

Upvotes: 21

jmarceli
jmarceli

Reputation: 20182

I would recommend you to check heroku add-on solution which is https://addons.heroku.com/cloudinary. You will get 500MB for free and easy heroku integration.

For RoR app you can check: https://devcenter.heroku.com/articles/cloudinary#using-with-ruby-on-rails

There is also documentation for Nodejs and Django.

Upvotes: 24

Related Questions