301 Moved Permanently after S3 uploading

前端 未结 2 1111
眼角桃花
眼角桃花 2020-12-10 13:34

Im trying to upload images to S3 on Ruby on Rails using carrierwave and fog gems, images are uploaded correctly but when I try tu save the model containing information about

相关标签:
2条回答
  • 2020-12-10 14:16
    <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></Error>
    

    This is a frequently encountered issue: You are trying to access a bucket in region us-west-1, however, for legacy reasons the default Amazon S3 region in most/all AWS SDKs is US Standard, which automatically routes requests to facilities in Northern Virginia or the Pacific Northwest using network maps (see Regions and Endpoints for details).

    Therefore you simply need to specify the endpoint of your buckets region explicitly before using the S3 API, e.g. for us-west-1:

      config.fog_credentials = {
        :provider               => 'AWS',
        :aws_access_key_id      => ENV['AWS_ACCESS_KEY_ID'],
        :aws_secret_access_key  => ENV['AWS_SECRET_ACCESS_KEY'],
        :region                 => 'us-west-1'
        :endpoint               => 'https://s3-us-west-1.amazonaws.com/'
      }
    
    0 讨论(0)
  • 2020-12-10 14:23

    Thanks again to Steffen Opel!

    But some consideration I haven't made, my region is US Standard, therefore, my carrierwave initializer looks like this: # :region => # NOT NEEDED BY US STANDARD :endpoint => 'https://s3.amazonaws.com'

    This link was the key :D

    0 讨论(0)
提交回复
热议问题