Skip to content

Instantly share code, notes, and snippets.

@wahyusumartha
Created July 13, 2011 06:19
Show Gist options
  • Save wahyusumartha/1079819 to your computer and use it in GitHub Desktop.
Save wahyusumartha/1079819 to your computer and use it in GitHub Desktop.
ruby dropbox uploader
require 'rubygems'
require 'dropbox'
CONSUMER_KEY = "YOUR-CONSUMER-KEY"
CONSUMER_SECRET = "YOUR-SECRET-KEY"
DROPBOX_SESSION_FILE = "/Users/wahyusumartha/Documents/mongodb-db/script/dropbox_session.txt"
# Using when we do not have session
# session = Dropbox::Session.new("#{CONSUMER_KEY}", "#{CONSUMER_SECRET}")
# session.mode = :dropbox
# puts "Visit #{session.authorize_url} to log in to Dropbox. Hit enter when you have done this."
#session.authorize
# Read from Previous Session
session = Dropbox::Session.deserialize(File.read("#{DROPBOX_SESSION_FILE}"))
session.mode = :dropbox
file_upload = ARGV[0]
session.upload("#{file_upload}", '/mongodb-backup')
puts "File has been upload to dropbox under /mongodb-backup directory"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment