Snapshot của zendesk/dropbox-api: 361★ · Ruby. Dropbox API Ruby Client
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
To deliver a more Rubyesque experience when using the Dropbox API.
Current state:
First release, whole API covered.
Important!!!
From version 0.2.0, Dropbox::API::File#delete and Dropbox::API::Dir#deleteare gone!!
The reason is that it's based on Hashie::Mash and was screwing Hash#delete.
It is replaced with Dropbox::API::File#destroy and Dropbox::API::Dir#destroy.
Installation
Dropbox::API is available on RubyGems, so:
gem install dropbox-api
Or in your Gemfile:
gem "dropbox-api"
Configuration
In order to use this client, you need to have an app created on https://www.dropbox.com/developers/apps.
Once you have it, put this configuration somewhere in your code, before you start working with the client.
Dropbox::API::Config.app_key = YOUR_APP_KEY
Dropbox::API::Config.app_secret = YOUR_APP_SECRET
Dropbox::API::Config.mode = "sandbox" # if you have a single-directory app
# Dropbox::API::Config.mode = "dropbox" # if your app has access to the whole dropbox
Dropbox::API::Client
The client is the base for all communication with the API and wraps around almost all calls
available in the API.
Web-based Authorization
In order to create a Dropbox::API::Client object, you need to have the configuration set up for OAuth.
Second thing you need is to have the user authorize your app using OAuth. Here's a short intro
on how to do this:
consumer = Dropbox::API::OAuth.consumer(:authorize)
request_token = consumer.get_request_token
# Store the token and secret so after redirecting we have the same request token
session[:token] = request_token.token
session[:token_secret] = request_token.secret
request_token.authorize_url(:oauth_callback => 'http://yoursite.com/callback')
# Here the user goes to Dropbox, authorizes the app and is redirected
# This would be typically run in a Rails controller
hash = { oauth_token: session[:token], oauth_token_secret: session[:token_secret]}
request_token = OAuth::RequestToken.from_hash(consumer, hash)
oauth_verifier = params[:oauth_verifier]
result = request_token.get_access_token(:oauth_verifier => oauth_verifier)
Now that you have the oauth token and secret, you can create a new instance of the Dropbox::API::Client, like this:
You will notice that you have a new rake task - dropbox:authorize
When you call this Rake task, it will ask you to provide the app key and app secret. Afterwards it will present you with an authorize url on Dropbox.
Simply go to that url, authorize the app, then press enter in the console.
The rake task will output valid ruby code which you can use to create a client.
What differs this from the Dropbox Ruby SDK?
A few things:
It's using the ruby oauth gem, instead of reinventing the wheel and implementing OAuth communication
It treats files and directories as Ruby objects with appropriate classes, on which you can perform operations
Consider the following example which takes all files with names like 'test.txt' and copies them with a suffix '.old'
This is how it would look using the SDK:
# Because you need the session with the right access token, you need to create one instance per user
@session = DropboxSession.new(APP_TOKEN, APP_SECRET)
@session.set_access_token(ACCESS_TOKEN, ACCESS_SECRET)
@client = DropboxClient.new(@session, :app_folder)
# The result is a hash, so we need to call a method on the client, supplying the right key from the hash
@client.search('/', 'test.txt').each do |hash|
@client.file_copy(hash['path'], hash['path'] + ".old")
end
With Dropbox::API, you can clean it up, first you put the app token and secret in a config or initializer file:
And when you want to use it, just create a new client object with a specific access token and secret:
# The app token and secret are read from config, that's all you need to have a client ready for one user
@client = Dropbox::API::Client.new(:token => ACCESS_TOKEN, :secret => ACCESS_SECRET)
# The file is a Dropbox::API::File object, so you can call methods on it!
@client.search('test.txt').each do |file|
file.copy(file.path + ".old2")
end
What differs this from the dropbox gem?
Dropbox::API does not extend the Ruby primitives, like the dropbox gem:
zendesk/dropbox-api có 361 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/zendesk/dropbox-api. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
zendesk/dropbox-api có tag gì không?
Bản đồng bộ chưa ghi nhận topic GitHub nào cho zendesk/dropbox-api. GitHub topics hiển thị ở thanh bên phải trang repo — đó là nơi đáng kiểm tra nhất.
zendesk/dropbox-api còn đang phát triển không?
Commit gần nhất trên zendesk/dropbox-api là 6.2 năm trước (theo timestamp GitHub). Repo có 77 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
zendesk/dropbox-api là gì?
zendesk/dropbox-api (zendesk/dropbox-api) là dự án Ruby trên GitHub. Theo mô tả gốc: Dropbox API Ruby Client
zendesk/dropbox-api viết bằng ngôn ngữ gì?
zendesk/dropbox-api chủ yếu viết bằng Ruby. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về dropbox-api?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về dropbox-api.