require 'net/http' require 'rubygems' require_gem 'flickr' require_gem 'net-sftp' flickr_username = "johan@johansorensen.com" flickr_pass = 'x' strongie_pass = 'x' strongie_username = 'johan' strongie_upload_dir = "flickr_test" flickr = Flickr.new flickr.login(flickr_username, flickr_pass) user = flickr.users(flickr_username) Net::SFTP.start("#{strongie_username}.strongspace.com", strongie_username, strongie_pass) do |sftp| Net::HTTP.start('static.flickr.com') do |http| user.photos.each do |photo| src_url = photo.source('Large').sub("http://static.flickr.com", '') puts "Fetching \"#{photo.title}\"..." res = http.get(src_url) filename = File.basename(src_url) sftp.open_handle("/home/#{strongie_username}/#{strongie_upload_dir}/#{filename}", 'w') do |handle| result = sftp.write(handle, res.body) puts "Wrote #{filename} with result code: #{result.code}..." end end end end
Never been to CodeSnippets before?
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
Upload your Flickr photos to Strongspace (See related posts)
You need to create an account or log in to post comments to this site.
Related Posts
» Daily rotated backups to Str... in backup strongspace
» Backup from textdrive to str... in mysql svn backup strongspace
» Mount Strongspace to a folde... in backup strongspace ubuntu fuse mount folder
» Postgresql dump SS archive s... in backup strongspace postgres
» Typo under lighttpd in lighttpd ruby rails typo ruby-fcgi
» password hash script in ruby password
Snippets (source code soon to be available) developed by Peter Cooper and powered by Ruby On Rails