Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependencies: How to create a fog directory #291

Open
ebbnormal opened this issue Jan 28, 2015 · 4 comments
Open

Dependencies: How to create a fog directory #291

ebbnormal opened this issue Jan 28, 2015 · 4 comments

Comments

@ebbnormal
Copy link

Hello. I am simply wondering if I have to use Fog in order to use this Gem. And if yes, how do I know what to put for the following item:

 heroku config:add FOG_DIRECTORY=xxxx

as I am getting the following error when I run bundle exec rake assets:precompile

AssetSync::Config::Invalid: Fog provider can't be blank, Fog directory can't be blank

I basically just don't know where to put the following code in my Rails app:

require 'rubygems'
require 'fog'

# create a connection
connection = Fog::Storage.new({
  :provider                 => 'AWS',
  :aws_access_key_id        => YOUR_AWS_ACCESS_KEY_ID,
  :aws_secret_access_key    => YOUR_AWS_SECRET_ACCESS_KEY
})

# First, a place to contain the glorious details
directory = connection.directories.create(
  :key    => "fog-demo-#{Time.now.to_i}", # globally unique name
  :public => true
)
@ebbnormal ebbnormal changed the title Dependencies: Fog? Dependencies: How to create a fog directory Jan 28, 2015
@denisinla
Copy link

+1 I'm having the same issues with this as well.

@denisinla
Copy link

@ebbnormal Looks like FOG_DIRECTORY=yourbucketname

@nguyenp5
Copy link

Same issue! Please help

@PikachuEXE
Copy link
Member

This is that I have in an initializer

begin
  require "asset_sync"
rescue LoadError
  # Do nothing
end
require "fog/aws"

if defined?(AssetSync)
  AssetSync.configure do |config|
    config.fog_provider           = 'AWS'
    config.fog_directory          = Rails.application.secrets.aws_s3_bucket_name

    config.aws_access_key_id      = Rails.application.secrets.aws_access_key_id
    config.aws_secret_access_key  = Rails.application.secrets.aws_access_secret_access_key

    # Increase upload performance by configuring your region
    # config.fog_region = 'eu-west-1'
    #
    # Don't delete files from the store
    # config.existing_remote_files = "keep"

    # Automatically replace files with their equivalent gzip compressed version
    config.gzip_compression = true

    # Use the Rails generated 'manifest.yml' file to produce the list of files to
    # upload instead of searching the assets directory.
    # config.manifest = true
    #
    # Fail silently.  Useful for environments such as Heroku
    # config.fail_silently = true

    # Log silently. Default is `true`. But you can set it to false if more logging message are preferred.
    # Logging messages are sent to `STDOUT` when `log_silently` is falsy
    config.log_silently = false

    puts "AssetSync initialized with bucket #{config.fog_directory}"
  end
end

You can replace calls to Rails.application.secrets with ENV
Asset sync gets fog info from it's own config

You can generate an initializer with
rails g asset_sync:install --provider=AWS
documented here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
@denisinla @PikachuEXE @ebbnormal @nguyenp5 and others