我无法使用 assets_sync 将我的资产上传到 S3
生产.rb
config.action_controller.asset_host = "//#{ENV['FOG_DIRECTORY']}.s3-eu-west-1.amazonaws.com"
config.assets.digest = true
config.assets.enabled = true
config.assets.initialize_on_precompile = true
资产同步.rb
if defined?(AssetSync)
AssetSync.configure do |config|
config.fog_provider = 'AWS'
config.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
config.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
config.fog_directory = ENV['FOG_DIRECTORY']
config.fog_region = 'eu-west-1'
end
end
heroku 配置
AWS_ACCESS_KEY_ID: XXX
AWS_SECRET_ACCESS_KEY: XXX
FOG_DIRECTORY: bucket_name
FOG_PROVIDER: AWS
FOG_REGION: 'eu-west-1'
$出口
declare -x AWS_ACCESS_KEY_ID= XXX
declare -x AWS_SECRET_ACCESS_KEY= XXX
declare -x FOG_DIRECTORY="bucket_name"
declare -x FOG_PROVIDER="AWS"
http://blog.firmhouse.com/complete-guide-to-serving-your-rails-assets-over-s3-with-asset_sync
那些推送heroku资产指向//bucket_name.s3-eu-west-1.amazonaws.com/assets/icons/name_xxxxxxxxxx.png
并且在运行$rake assets:precompile
文件时不会上传到S3并且只能在本地进行预编译。任何想法 ?非常感谢。
编辑:
我刚刚将 Gemfile 从:
group :assets do
gem 'asset_sync'
end
到全球宝石
gem 'asset_sync'
现在我收到警告信息[WARNING] fog: followed redirect to bucket_name.s3-external-3.amazonaws.com, connecting to the matching region will be more performant
我想我可以解决这个问题,但只有 css 文件被上传,而不是 js 文件和图像。