【问题标题】:how to retrieve image link from S3 bucket如何从 S3 存储桶中检索图像链接
【发布时间】:2014-04-02 13:33:09
【问题描述】:

我可以将图像上传到 s3 存储桶。 然后我检索包含图像链接的 JSON 对象。 这是指向存储桶的 URL。

网址:“https://s3.amazonaws.com/bucket-name/uploads/recepie/image/21/2013-12-13_23.25.58.jpg

当我按下它时,我得到一个错误

 <Error>
 <Code>PermanentRedirect</Code>
 <Message>
 The bucket you are attempting to access must be addressed using the specified endpoint.        Please send all future requests to this endpoint.       
 </Message>
<RequestId>2227C463FE87702A</RequestId>
<Bucket>bucket-name</Bucket>
<HostId>
20obskM************FmRoYcMDnMlH
</HostId>
<Endpoint>bucket-name.s3.amazonaws.com</Endpoint>
</Error>

我正在使用带有载波和雾宝石的 RoR。

【问题讨论】:

  • 存储桶名称应该在那里!

标签: ruby-on-rails-4 amazon-s3 amazon carrierwave fog


【解决方案1】:
【解决方案2】:

试试这个, 我遇到了同样的问题并通过以下方式解决:

CarrierWave.configure do |config|
  config.fog_credentials = {
    :provider               => 'AWS', # required
    :aws_access_key_id      => '******', # required
    :aws_secret_access_key  => '******', # required
  }
  config.fog_directory  = '******' # required(Your bucket name)
  config.fog_public     = false  # optional, defaults to true
  config.fog_attributes = {'Cache-Control'=>'max-age=315576000'} # optional, defaults to {}
end

【讨论】:

    【解决方案3】:

    我必须替换以下内容并在端点中指定我的存储桶区域:

    :endpoint               => 'https://s3.amazonaws.com'
    

    与:

    :endpoint   => 'https://s3-us-west-2.amazonaws.com'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-15
      • 2018-03-14
      • 1970-01-01
      • 2021-07-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多