Skip to content

Instantly share code, notes, and snippets.

@namxam
Created May 13, 2011 11:11
Show Gist options
  • Save namxam/970361 to your computer and use it in GitHub Desktop.
Save namxam/970361 to your computer and use it in GitHub Desktop.
typhoeus example
require 'rubygems'
require 'typhoeus'
hydra = Typhoeus::Hydra.new
# Create all your requests
request = Typhoeus::Request.new("http://your_image_url")
request.on_complete do |response|
# Check if the returned data really is an image
# Save the fetched file / image
File.open(file_path, 'w+') do |file|
file.write(response.body)
end
# Do some post processing like resizing
end
hydra.queue request
hydra.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment