首页 文章

如何从S3存储桶中检索图像链接

提问于
浏览
1

我可以将Image上传到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 .

3 回答

  • 0

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

    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
    
  • 1

    我必须替换follow并在 endpoints 中指定我的bucket区域:

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

    有:

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

相关问题