Heroku文件存储 [英] Heroku File Storage

查看:178
本文介绍了Heroku文件存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Heroku只有100MB的文件存储空间,对吧?我正在制作一个低级Rails应用程序,我非常喜欢Heroku,但是如果我的应用程序允许每个用户上传一张图片,我可能会很快耗尽空间......是否有一个简单的解决方案,可以让我有替代方案文件存储的配置文件图片或类似的东西?

解决方案

请参阅此博文



在你的

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



配置目录:

 开发:
bucket:bucketname
access_key_id:key
secret_access_key:key

制作:
存储桶:存储桶名称
access_key_id:存储钥匙
secret_access_key:钥匙

然后注册Amazon S3中的存储桶: http:// aws。 amazon.com/s3/


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?

解决方案

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/

这篇关于Heroku文件存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆