Skip to content

Instantly share code, notes, and snippets.

@fujimura
Created January 5, 2012 11:36
Show Gist options
  • Select an option

  • Save fujimura/1564907 to your computer and use it in GitHub Desktop.

Select an option

Save fujimura/1564907 to your computer and use it in GitHub Desktop.
require 'fog'
require 'carrierwave'
require 'tempfile'
Fog.mock!
fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => 'a',
:aws_secret_access_key => 'b'
}
module CarrierWave
module Storage
class Fog < Abstract
end
end
end
CarrierWave.configure do |config|
config.storage :fog
config.reset_config
config.fog_credentials = fog_credentials
config.fog_host = nil
config.fog_public = true
config.fog_directory = 'directory'
end
class MyUploader < CarrierWave::Uploader::Base
end
uploader = MyUploader.new
storage = CarrierWave::Storage::Fog.new(uploader)
storage.connection.directories.create(:key => CarrierWave::Uploader::Base.fog_directory)
files = []
500.times.map.with_index do |i|
tempfile = Tempfile.new 'a'
sanitized_file = CarrierWave::SanitizedFile.new(tempfile)
storage.store!(sanitized_file)
files << sanitized_file
puts "stored #{i} times"
end
p files.count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment