1

I am able to upload Image to s3 bucket. I then retrieve the JSON object containing image link. this is the URL pointing to the bucket.

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

When i press it I get an error

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

I am using RoR with carrierwave and fog gems.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
JY2k
  • 2,879
  • 1
  • 31
  • 60

3 Answers3

1

Try this, I faced same problem and resolve by following:

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
Sourabh Upadhyay
  • 1,034
  • 11
  • 31
0

I had to replace the follow and specify my bucket region in the endpoint:

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

with:

:endpoint   => 'https://s3-us-west-2.amazonaws.com'
JY2k
  • 2,879
  • 1
  • 31
  • 60