1

I'm have trouble uploading my assets to S3 with asset_sync

production.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

asset_sync.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 config

AWS_ACCESS_KEY_ID:   XXX
AWS_SECRET_ACCESS_KEY: XXX
FOG_DIRECTORY: bucket_name
FOG_PROVIDER:  AWS
FOG_REGION: 'eu-west-1'

$export

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

ones push on heroku assets points to //bucket_name.s3-eu-west-1.amazonaws.com/assets/icons/name_xxxxxxxxxx.png and when running $rake assets:precompile the files dose not get uploaded to S3 and gets only precompile locally. Any idea ? Thanks a lot.

EDIT:

I've just changed the Gemfile from :

  group :assets do
   gem 'asset_sync'
  end

to the global gems

 gem 'asset_sync'

and now I having warning message [WARNING] fog: followed redirect to bucket_name.s3-external-3.amazonaws.com, connecting to the matching region will be more performant

I think I can figure this out, but only the css files gets uploaded.not the js file and images.

Nicolas Duval
  • 167
  • 1
  • 9
  • Check the official `asset_sync` docs for detailed info, https://github.com/rumblelabs/asset_sync – Ameen Oct 13 '13 at 09:40

1 Answers1

1

Your bucket_name needs to be the bucket you have on S3

You should change these commands:

Heroku
FOG_DIRECTORY: your_bucket_real_name

Local
declare -x FOG_DIRECTORY=your_bucket_real_name

Also, you should change this in your production.rb file:

config.action_controller.asset_host = "//#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com"

I think that will resolve your issue. I'm using S3 on EU-West with exactly the same setup (bar the differences I've cited), and it's working in the most part :)

Richard Peck
  • 76,116
  • 9
  • 93
  • 147