require 'rubygems' require 'open-uri' storage = Fog::Storage.new( provider: 'AWS', aws_access_key_id:ENV['AWS_S3_KEY_ID'], aws_secret_access_key:ENV['AWS_S3_SECRET_KEY'], region: ENV['AWS_REGION'] ) bucket = storage.directories.get(ENV['AWS_S3_BUCKET']) bucket = storage.directories.create(key: ENV['AWS_S3_BUCKET']) unless bucket path_to_save = 'users/images/hoge2.png' image_url = 'http://a0.twimg.