Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails aws sdk 2.3.0和回形针5.0.0坏区_Ruby On Rails_Amazon Web Services_Amazon S3_Paperclip - Fatal编程技术网

Ruby on rails aws sdk 2.3.0和回形针5.0.0坏区

Ruby on rails aws sdk 2.3.0和回形针5.0.0坏区,ruby-on-rails,amazon-web-services,amazon-s3,paperclip,Ruby On Rails,Amazon Web Services,Amazon S3,Paperclip,Im使用AWS-SDK2.3.0gem和回形针5.0.0gem 在我的config/environment/development.rb文件中 config.paperclip_defaults = { storage: :s3, s3_region: 'eu-west-1', s3_credentials: { bucket: 'myBucketName', access_key_id: 'xxxxxxxxxxxxxxxxxxxxxx',

Im使用AWS-SDK2.3.0gem和回形针5.0.0gem

在我的
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'
      }
    }
我的bucket区域在创建bucket时设置为Ireland,因此根据AWS提供的文档,我将s3区域设置为
eu-west-1

我假设我的详细信息都是正确的,但当我上传一张图片时,它会被保存到bucket中,但不会显示在我的rails应用程序上。如果在“新建”选项卡中右键单击“打开图像”,则会出现以下错误:

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

您试图访问的存储桶必须使用指定的端点寻址。请将所有未来请求发送到此终结点。

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

阿米纳里亚纳于3月25日发表评论 目前的解决方法:配置 s3\u主机\u名称到s3-[region].amazonaws.com,如下所示:

config.paperclip_默认值={s3_主机名称: “s3-#{ENV['AWS_REGION']}.amazonaws.com,}”


只需通过谷歌搜索准确的错误消息就可以找到此btw。

解决此问题的方法是创建一个名为:

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'

在第三行中,我有
eu-west-1
根据您所在的地区替换它。

我也遇到了这个问题。对我来说,问题是我在ENV中指定了错误的区域。确保通过单击bucket的“properties”来检查S3中的区域。我只是在亚马逊控制台的URL栏中查看区域,这可能正是我所在的区域


另外,请注意,美国东部(北弗吉尼亚州)的美国标准区域,其区域字符串为
US-East-1

its会保存到存储桶中,但不会显示在我的rails应用程序中。这是一个有趣的行为组合。右键单击并打开“新建”选项卡时,URL的主机名是什么?“指定端点”错误消息应提及端点。它列出了什么端点?从失败的下载中捕获HTTP响应头也可能很有用。(使用
curl-v'http…“
是一种很好的方法,可以捕获这些信息,并将其编辑到您的问题中)。@GurmukhSingh您应该在问题中提到这一点。在测试建议的解决方案时,您还应该非常小心,确认解决方案中的错误在所有有意义的方面都是相同的。“同样失败”并不等于“不正确”