Rails 4:Heroku + Paperclip + s3不能用于生产 [英] Rails 4: Heroku + Paperclip + s3 not working in production

查看:104
本文介绍了Rails 4:Heroku + Paperclip + s3不能用于生产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

https://devcenter.heroku.com/articles/paperclip- s3



我设法将其部署到Heroku,App正在开发中。该应用程序在Heroku中运行,但是当我尝试上传照片时。它给了我这个页面


我们很抱歉,但出错了。


我尝试去控制台并输入heroku日志来调试它,它给了我以下错误:


heroku [router]:at = info method = POST path =/ friends
host = s3friends.herokuapp.com
request_id = 4173ed9e-ed69-492c-b1b9-d98227ca678c fwd =98.207。 140.59
dyno = web.1 connect = 9ms service = 2668ms status = 500 bytes = 1754

Production.rb

  config.paperclip_defaults = {
:storage => :s3,
:s3_credentials => {
:bucket => ENV ['S3_BUCKET_NAME'],
:access_key_id => ENV ['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV ['AWS_SECRET_ACCESS_KEY']
}
}

gem文件: p>

  gem'aws-sdk'
gem'rails','4.2.5'

group:production do
gem'pg'
end

我也是确保我的heroku配置上的凭证与我s3上的凭证相匹配。



任何帮助都将得到极大的处理。

解决方案

添加区域 s3_host_name

  config.paperclip_defaults = {
storage :: s3,
s3_credentials:{
bucket:ENV [S3_BUCKET_NAME ],
access_key_id:ENV [AWS_ACCESS_KEY_ID],
secret_access_key:ENV [AWS_SECRET_ACCESS_KEY],
s3_region:ENV [S3_REGION],
s3_host_name:ENV [ S3_HOST_NAME]
}



S3_REGION =eu-central-1
S3_HOST_NAME =s3.eu-central-1.amazonaws.com



地区和端点: http ://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region



使用 gem aws-sdk,〜> 2.0


so im following this tutorial: https://devcenter.heroku.com/articles/paperclip-s3

I manage to deploy it to Heroku and App is working in the development. The app is running in Heroku but when i try to upload photo. it gives me this page

We're sorry, but something went wrong.

I try to debug it by going to console and typing heroku logs it gives me the following error:

heroku[router]: at=info method=POST path="/friends" host=s3friends.herokuapp.com request_id=4173ed9e-ed69-492c-b1b9-d98227ca678c fwd="98.207.140.59" dyno=web.1 connect=9ms service=2668ms status=500 bytes=1754

Production.rb

config.paperclip_defaults = {
    :storage => :s3,
    :s3_credentials => {
      :bucket => ENV['S3_BUCKET_NAME'],
      :access_key_id => ENV['AWS_ACCESS_KEY_ID'],
      :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
    }
  }

gem file:

gem 'aws-sdk'
gem 'rails', '4.2.5'

group :production do
    gem 'pg'
end

I've also made sure that the credential on my heroku config match the credential on my s3.

any help would be greatly appreacted.

解决方案

Add region and s3_host_name.

config.paperclip_defaults = {
    storage: :s3,
    s3_credentials: {
      bucket: ENV["S3_BUCKET_NAME"],
      access_key_id: ENV["AWS_ACCESS_KEY_ID"],
      secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"],
      s3_region: ENV["S3_REGION"],
      s3_host_name: ENV["S3_HOST_NAME"]
    }

S3_REGION="eu-central-1" S3_HOST_NAME="s3.eu-central-1.amazonaws.com"

Regions and endpoints: http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region

Using gem "aws-sdk", "~> 2.0"

这篇关于Rails 4:Heroku + Paperclip + s3不能用于生产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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