[英]Rails 4.2 + Paperclip + Amazon s3: getaddrinfo: nodename nor servname provided, or not known
Even though this error it is present in other SO questions, I've not been able to work arround so I'm seeking for help. 即使此错误出现在其他SO问题中,我也无法解决问题,因此我正在寻求帮助。
I'm using rails 4.2.5
, paperclip ~>4.1
, aws-sdk <2.0
to store attached files into Amazon S3
. 我正在使用
rails 4.2.5
, paperclip ~>4.1
, aws-sdk <2.0
将附件存储到Amazon S3
。
I've creadted a bucket
and a IAM User
who has AmazonS3FullAccess
permissions and with his credentials I'm trying to connect from Rails like this. 我已经烦恼了一个
bucket
和一个具有AmazonS3FullAccess
权限的IAM User
,并使用他的凭据试图从Rails这样连接。
config/environments/development.rb config / environments / development.rb
config.paperclip_defaults = {
:storage => :s3,
:s3_credentials => {
:bucket => 'bucket-name',
:access_key_id => '****',
:secret_access_key => '****',
}
}
app/models/user.rb app / models / user.rb
has_attached_file :avatar,
:styles => { :medium => "300x300#", :thumb => "100x100#" },
:default_url => "/img/avatar-missing.jpg",
:storage => :s3,
:s3_host_name => "s3-us-east-1.amazonaws.com"
I configured the bucket permissions with this policy 我使用此策略配置了存储桶权限
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AddPerm",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": [
"arn:aws:s3:::bucket-name/*"
]
}
]
}
But when I try to upload something to it, it throws me this ******* error: 但是,当我尝试向其上载某些内容时,它会抛出以下*******错误:
getaddrinfo: nodename nor servname provided, or not known
In the console I can see that paperclip is able to resize the picture but it is not able to upload it to Amazon S3 在控制台中,我可以看到回形针可以调整图片大小,但是无法将其上传到Amazon S3
[paperclip] saving /users/avatars/000/000/001/original/10382845_246916218831306_3480489092212800336_n.jpg
[AWS S3 200 2.304022 3 retries] put_object(:acl=>:public_read,:bucket_name=>"bucket-name",:content_length=>41431,:content_type=>"image/jpeg",:data=>Paperclip::UploadedFileAdapter: 10382845_246916218831306_3480489092212800336_n.jpg,:key=>"users/avatars/000/000/001/original/10382845_246916218831306_3480489092212800336_n.jpg") SocketError getaddrinfo: nodename nor servname provided, or not known
Any help will be highly appreciated 任何帮助将不胜感激
Can you try to configure the model like this: 您可以尝试像这样配置模型吗?
has_attached_file :my_file,
:storage => :s3,
:default_url => "/default.default",
:s3_region => ENV['AWS_REGION'],
:s3_credentials => {
:bucket => ENV['AWS_BUCKET_NAME'],
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'],
:region => ENV['AWS_REGION']
}
sometimes the issue is that a region is not defined and the configuration fails. 有时问题是未定义区域并且配置失败。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.