Skip to content

Instantly share code, notes, and snippets.

@naoto
Created January 20, 2010 07:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naoto/281686 to your computer and use it in GitHub Desktop.
Save naoto/281686 to your computer and use it in GitHub Desktop.
Flickr Uploader
#!/usr/bin/env ruby
require 'rubygems'
require 'flickr'
require 'fileutils'
api_key = ""
secret = ""
flickr = Flickr.new('flickr.dat',api_key, secret)
unless flickr.auth.token
flickr.auth.getFrob
url = flickr.auth.login_link
puts "Acccess! #{url} "
gets
flickr.auth.getToken
flickr.auth.cache_token
end
Dir.glob('*.{JPG,jpg,jpeg,png}').each do |f|
begin
flickr.photos.upload.upload_file(f, f)
puts "#{Time.now} upload success #{f}"
FileUtils.cp("./#{f}", "../uploded/#{f}")
File.delete("./#{f}")
rescue
puts "#{Time.now} error raised"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment