This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Updated README and added example

  • Loading branch information...
RISCfuture committed Jan 14, 2011
1 parent d8e78cf commit fe3dc45041d5ab87a79635cb5abdc0ec2262d27a
Showing with 26 additions and 1 deletion.
  1. +2 −1 README.rdoc
  2. +24 −0 examples/upload_and_delete.rb
View
@@ -13,13 +13,14 @@ http://developers.dropbox.com
# STEP 1: Authorize the user
session = Dropbox::Session.new('your_consumer_key', 'your_consumer_secret')
session.mode = :sandbox # might need to set this to :dropbox; consult your API account page
puts "Visit #{session.authorize_url} to log in to Dropbox. Hit enter when you have done this."
gets
session.authorize
# STEP 2: Play!
session.upload('testfile.txt')
uploaded_file = session.file('testfile.txt')
uploaded_file = session.file('testfile.txt', '/')
puts uploaded_file.metadata.size
uploaded_file.move 'new_name.txt'
@@ -0,0 +1,24 @@
require 'dropbox'
unless File.exist?('keys.json')
raise "Create a keys.json file with your Dropbox API credentials. See keys.json.example to get started."
end
settings = JSON.parse(File.read('keys.json'))
session = Dropbox::Session.new(settings['key'], settings['secret'])
session.mode = :sandbox
puts "Visit #{session.authorize_url} to log in to Dropbox. Hit enter when you have done this."
gets
session.authorize
# upload a file
puts "Uploading ChangeLog..."
session.upload 'ChangeLog', '/'
uploaded_file = session.file('ChangeLog')
puts "Done! #{uploaded_file.inspect}"
puts uploaded_file.metadata.size
puts "Deleting file..."
uploaded_file.delete
puts "Done!"

0 comments on commit fe3dc45

Please sign in to comment.