Heroku File Storage

两盒软妹~` 提交于 2019-11-28 18:30:44

问题


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?


回答1:


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/




回答2:


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.



来源:https://stackoverflow.com/questions/6657015/heroku-file-storage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!