2016-10-30 37 views
-2

Im使用AWS-SDK 2.3.0宝石与paperclip 5.0.0宝石。aws-sdk 2.3.0和Paperclip 5.0.0不良区域

在我config/environment/development.rb文件我有

config.paperclip_defaults = { 
    storage: :s3, 
    s3_region: 'eu-west-1', 
    s3_credentials: { 
     bucket: 'myBucketName', 
     access_key_id: 'xxxxxxxxxxxxxxxxxxxxxx', 
     secret_access_key: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx' 
     } 
    } 

我斗区集爱尔兰时,我建立了我的水桶所以根据AWS提供的文档设置我的S3地区eu-west-1

我假设我的细节都是正确的,但是,当我上传图片时,它会被保存到存储桶中,但它不会显示在我的导轨应用程序中。如果我在新标签中右键点击打开的图像,我会得到这个错误:

<Message> 
The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint. 
</Message> 
+0

*它被保存到存储桶中,但它不会显示在我的rails应用程序中*这是一个有趣的行为组合。当您右键单击并打开新选项卡时,该URL的主机名是什么? “指定的端点”错误消息应提及一个端点。它列出了什么终端?从失败的下载中捕获HTTP响应头也许很有用。 (使用'curl -v'http ...'是捕获这个问题的好方法,并将其编辑到你的问题中)。 –

回答

0

解决这个问题的工作是创建一个文件名为:

config/initializers/paperclip.rb 

,并添加以下:

Paperclip::Attachment.default_options[:url] = ':s3_domain_url' 
Paperclip::Attachment.default_options[:path] = '/:class/:attachment/:id_partition/:style/:filename' 
Paperclip::Attachment.default_options[:s3_host_name] = 's3-eu-west-1.amazonaws.com' 

并在第3行,我有eu-west-1的是,根据区域更换都在。

-1

这看起来像维护回形针的团队已知的问题。

https://github.com/thoughtbot/paperclip/issues/2151

aminariana commented on Mar 25 Workaround for now: Configure s3_host_name to s3-[region].amazonaws.com like so:

config.paperclip_defaults = { s3_host_name: "s3-#{ENV['AWS_REGION']}.amazonaws.com", }

仅仅用了谷歌搜索确切的错误消息BTW找到。

+0

已经试过这个,这就是为什么我在这里发布错误 –

+1

@GurmukhSingh你应该在你的问题中提到这个。在测试提议的解决方案时,您应该非常小心,确认解决方案存在的错误在每个有意义的方面都是相同的。 “也失败”并不等同于“不正确”。 –

0

我也有这个问题。对我而言,问题在于我在ENV中指定了错误的区域。确保通过点击您的存储桶的“属性”来检查S3中的区域。我只是在亚马逊控制台的URL栏中查看该区域,这可能就是我所在的区域。

此外,请注意美国标准区域was renamed到美国东部(弗吉尼亚北部),与其区域字符串为us-east-1