Jonathan
Jonathan

Reputation: 683

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.

Upvotes: 1

Views: 464

Answers (1)

Parker Selbert
Parker Selbert

Reputation: 1546

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

Upvotes: 3

Related Questions