简体   繁体   中英

S3 + Carrierwave

I'm currently fighting to get S3 uploads to work via Carrierwave, Carrierwave-aws & Figaro.

I've got it all set up but it keeps returning

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

config/initializers/carrierwave.rb (Set up according to carrierwave-aws)

CarrierWave.configure do |config|
  config.storage    = :aws
  config.aws_bucket = ENV.fetch('S3_BUCKET_NAME')
  config.aws_acl    = 'public-read'

  # Optionally define an asset host for configurations that are fronted by a
  # content host, such as CloudFront.
  config.asset_host = 'http://example.com'

  # The maximum period for authenticated_urls is only 7 days.
  config.aws_authenticated_url_expiration = 60 * 60 * 24 * 7

  # Set custom options such as cache control to leverage browser caching
  config.aws_attributes = {
    expires: 1.week.from_now.httpdate,
    cache_control: 'max-age=604800'
  }

  config.aws_credentials = {
    access_key_id:     ENV.fetch('AWS_ACCESS_KEY_ID'),
    secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY'),
    region:            ENV.fetch('AWS_REGION') # Required
  }

end

Figaro application.yml

AWS_ACCESS_KEY_ID: "RANDOMNUMBERSKEY"
AWS_SECRET_ACCESS_KEY: "RANDOMNUMBERSKEY"
S3_BUCKET_NAME: "random-bucket-123"
AWS_REGION: "us-west-2"

On AWS Console my Bucket is located in

Region: US Standard

Any help would be greatly appreciated.

Your configuration looks fine, with the exception of the asset_host . You certainly don't have example.com as your asset host.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM