Created
January 5, 2012 11:36
-
-
Save fujimura/1564907 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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