[英]Rails 4 + Devise + Paperclip + S3 Example?
Can anyone upload a simple, working Rails 4 + Devise + Paperclip + S3 example application (to GitHub or something)? 任何人都可以上传一个简单的,工作的Rails 4 + Devise + Paperclip + S3示例应用程序(到GitHub或其他东西)? I just want to upload an avatar to S3 with Paperclip in the User model.
我只想在用户模型中使用Paperclip将头像上传到S3。 I really can't get this working.
我真的不能让这个工作。 Thanks!
谢谢!
Why not try this yourself ? 为什么不亲自尝试一下? It's really straightforward.
这真的很简单。
In your gemfile: 在你的gemfile中:
gem 'devise'
gem 'paperclip'
gem 'aws-sdk1'
Follow instructions at https://github.com/plataformatec/devise 按照https://github.com/plataformatec/devise上的说明操作
After that follow paperclip instructions 之后按照回形针说明进行操作
https://github.com/thoughtbot/paperclip/ https://github.com/thoughtbot/paperclip/
Pay attention to your S3 region (s3_host_name, use the eu-west url if in eu etc.): 注意你的S3区域(s3_host_name,如果在欧盟中使用eu-west url等):
https://github.com/thoughtbot/paperclip/wiki/Paperclip-with-Amazon-S3 https://github.com/thoughtbot/paperclip/wiki/Paperclip-with-Amazon-S3
config.paperclip_defaults = {
:storage => :s3,
:s3_host_name => 's3-us-west-2.amazonaws.com',
:bucket => 'S3_BUCKET_NAME'
}
And your done! 你做完了!
This way, by reading the install instructions you also won't forget to install things like Imagemagick, the library where paperclip depends on. 这样,通过阅读安装说明,您也不会忘记安装Papermagick之类的东西,这是paperclip所依赖的库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.