Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
= Ruby Dropbox Gem
An easy-to-use third-party interface to the RESTful Dropbox API.
== Installation
gem install dropbox
== Tutorial by Example
First things first: Be sure you've gotten a consumer key and secret from http://developers.dropbox.com
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
session.upload('testfile.txt', '/') uploaded_file = session.file('testfile.txt') puts uploaded_file.metadata.size
uploaded_file.move 'new_name.txt' uploaded_file.delete
File.open('serialized_session.txt', 'w') do |f| f.puts session.serialize end
new_session = Dropbox::Session.deserialize(File.read('serialized_session.txt')) account = new_session.account puts account.display_name
== Tutorial by Example, Rails Edition
A simple Rails controller that allows a user to first authorize their Dropbox account, and then upload a file to their Dropbox.
class DropboxController < ApplicationController def authorize if params[:oauth_token] then dropbox_session = Dropbox::Session.deserialize(session[:dropbox_session]) dropbox_session.authorize(params) session[:dropbox_session] = dropbox_session.serialize # re-serialize the authenticated session
redirect_to :action => 'upload'
else
dropbox_session = Dropbox::Session.new('your_consumer_key', 'your_consumer_secret')
session[:dropbox_session] = dropbox_session.serialize
redirect_to dropbox_session.authorize_url(:oauth_callback => url_for(:action => 'authorize'))
end
end
def upload return redirect_to(:action => 'authorize') unless session[:dropbox_session] dropbox_session = Dropbox::Session.deserialize(session[:dropbox_session]) return redirect_to(:action => 'authorize') unless dropbox_session.authorized?
if request.method == :post then
dropbox_session.upload params[:file], 'My Uploads'
render :text => 'Uploaded OK'
else
# display a multipart file field form
end
end end
== Features and Where to Find Them
== Testing Your Code
The gem is fully specced. Run specs with +rake spec+. Before doing so, you will need to create a file called +keys.json+ in the project root containing your Dropbox API key and secret, as well as the email and password for a Dropbox account. See the +keys.json.example+ file to get started.
fguillen has implemented a mock of the Dropbox API server: http://github.com/fguillen/DummyDropbox
== Note on Patches/Pull Requests
== Copyright
Copyright (c) 2009 Tim Morgan. See LICENSE for details.
FAQs
Unknown package
We found that dropbox demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.