S3+载波
S3 + Carrierwave
我目前正在努力让 S3 上传通过 Carrierwave、Carrierwave-aws 和 Figaro 工作。
我已经设置好了,但它一直在返回
'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(根据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
费加罗 application.yml
AWS_ACCESS_KEY_ID: "RANDOMNUMBERSKEY"
AWS_SECRET_ACCESS_KEY: "RANDOMNUMBERSKEY"
S3_BUCKET_NAME: "random-bucket-123"
AWS_REGION: "us-west-2"
在 AWS 控制台上,我的存储桶位于
地区:美国标准
如有任何帮助,我们将不胜感激。
您的配置看起来不错,但 asset_host
除外。您肯定没有 example.com
作为您的资产托管人。
我目前正在努力让 S3 上传通过 Carrierwave、Carrierwave-aws 和 Figaro 工作。
我已经设置好了,但它一直在返回
'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(根据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
费加罗 application.yml
AWS_ACCESS_KEY_ID: "RANDOMNUMBERSKEY"
AWS_SECRET_ACCESS_KEY: "RANDOMNUMBERSKEY"
S3_BUCKET_NAME: "random-bucket-123"
AWS_REGION: "us-west-2"
在 AWS 控制台上,我的存储桶位于
地区:美国标准
如有任何帮助,我们将不胜感激。
您的配置看起来不错,但 asset_host
除外。您肯定没有 example.com
作为您的资产托管人。