{"id":13858881,"url":"https://github.com/zendesk/dropbox-api","last_synced_at":"2025-07-14T01:31:59.804Z","repository":{"id":1786557,"uuid":"2710429","full_name":"zendesk/dropbox-api","owner":"zendesk","description":"Dropbox API Ruby Client","archived":true,"fork":false,"pushed_at":"2020-08-21T07:31:40.000Z","size":210,"stargazers_count":361,"open_issues_count":17,"forks_count":78,"subscribers_count":31,"default_branch":"master","last_synced_at":"2025-06-24T12:57:54.622Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"nodeschool/nodeschool.github.io","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zendesk.png","metadata":{"files":{"readme":"README.markdown","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-11-04T16:11:17.000Z","updated_at":"2025-05-14T07:36:11.000Z","dependencies_parsed_at":"2022-09-15T15:12:13.673Z","dependency_job_id":null,"html_url":"https://github.com/zendesk/dropbox-api","commit_stats":null,"previous_names":["futuresimple/dropbox-api"],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/zendesk/dropbox-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zendesk%2Fdropbox-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zendesk%2Fdropbox-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zendesk%2Fdropbox-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zendesk%2Fdropbox-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zendesk","download_url":"https://codeload.github.com/zendesk/dropbox-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zendesk%2Fdropbox-api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265231151,"owners_count":23731530,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-05T03:02:24.006Z","updated_at":"2025-07-14T01:31:59.522Z","avatar_url":"https://github.com/zendesk.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"Dropbox::API - Dropbox Ruby API client\n=========\n\nA Ruby client for the Dropbox REST API.\n\nGoal:\n\nTo deliver a more Rubyesque experience when using the Dropbox API.\n\nCurrent state:\n\nFirst release, whole API covered.\n\nImportant!!!\n------------\n\nFrom version 0.2.0, `Dropbox::API::File#delete` and `Dropbox::API::Dir#delete` *are gone*!!\n\nThe reason is that it's based on Hashie::Mash and was screwing Hash#delete.\n\nIt is replaced with `Dropbox::API::File#destroy` and `Dropbox::API::Dir#destroy`.\n\nInstallation\n------------\n\nDropbox::API is available on RubyGems, so:\n\n```\ngem install dropbox-api\n```\n\nOr in your Gemfile:\n\n```ruby\ngem \"dropbox-api\"\n```\n\nConfiguration\n-------------\n\nIn order to use this client, you need to have an app created on https://www.dropbox.com/developers/apps.\n\nOnce you have it, put this configuration somewhere in your code, before you start working with the client.\n\n```ruby\nDropbox::API::Config.app_key    = YOUR_APP_KEY\nDropbox::API::Config.app_secret = YOUR_APP_SECRET\nDropbox::API::Config.mode       = \"sandbox\" # if you have a single-directory app\n# Dropbox::API::Config.mode       = \"dropbox\" # if your app has access to the whole dropbox\n```\n\nDropbox::API::Client\n--------------------\n\nThe client is the base for all communication with the API and wraps around almost all calls\navailable in the API.\n\nWeb-based Authorization\n-----------------------\n\nIn order to create a Dropbox::API::Client object, you need to have the configuration set up for OAuth.\nSecond thing you need is to have the user authorize your app using OAuth. Here's a short intro\non how to do this:\n\n```ruby\nconsumer = Dropbox::API::OAuth.consumer(:authorize)\nrequest_token = consumer.get_request_token\n# Store the token and secret so after redirecting we have the same request token\nsession[:token] = request_token.token\nsession[:token_secret] = request_token.secret\nrequest_token.authorize_url(:oauth_callback =\u003e 'http://yoursite.com/callback')\n# Here the user goes to Dropbox, authorizes the app and is redirected\n# This would be typically run in a Rails controller\nhash = { oauth_token: session[:token], oauth_token_secret: session[:token_secret]}\nrequest_token  = OAuth::RequestToken.from_hash(consumer, hash)\noauth_verifier = params[:oauth_verifier]\nresult = request_token.get_access_token(:oauth_verifier =\u003e oauth_verifier)\n```\n\nNow that you have the oauth token and secret, you can create a new instance of the Dropbox::API::Client, like this:\n\n```ruby\nclient = Dropbox::API::Client.new :token =\u003e result.token, :secret =\u003e result.secret\n```\n\nRake-based authorization\n------------------------\n\nDropbox::API supplies you with a helper rake which will authorize a single client. This is useful for development and testing.\n\nIn order to have this rake available, put this on your Rakefile:\n\n```ruby\nrequire \"dropbox-api\"\nrequire \"dropbox-api/tasks\"\nDropbox::API::Tasks.install\n```\n\nYou will notice that you have a new rake task - dropbox:authorize\n\nWhen 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.\n\nSimply go to that url, authorize the app, then press enter in the console.\n\nThe rake task will output valid ruby code which you can use to create a client.\n\nWhat differs this from the Dropbox Ruby SDK?\n--------------------------------------------\n\nA few things:\n\n* It's using the ruby oauth gem, instead of reinventing the wheel and implementing OAuth communication\n* It treats files and directories as Ruby objects with appropriate classes, on which you can perform operations\n\nConsider the following example which takes all files with names like 'test.txt' and copies them with a suffix '.old'\n\nThis is how it would look using the SDK:\n\n```ruby\n# Because you need the session with the right access token, you need to create one instance per user\n@session = DropboxSession.new(APP_TOKEN, APP_SECRET)\n@session.set_access_token(ACCESS_TOKEN, ACCESS_SECRET)\n@client = DropboxClient.new(@session, :app_folder)\n# The result is a hash, so we need to call a method on the client, supplying the right key from the hash\n@client.search('/', 'test.txt').each do |hash|\n  @client.file_copy(hash['path'], hash['path'] + \".old\")\nend\n```\n\nWith Dropbox::API, you can clean it up, first you put the app token and secret in a config or initializer file:\n\n```ruby\nDropbox::API::Config.app_key    = APP_TOKEN\nDropbox::API::Config.app_secret = APP_SECRET\n```\n\nAnd when you want to use it, just create a new client object with a specific access token and secret:\n\n```ruby\n# The app token and secret are read from config, that's all you need to have a client ready for one user\n@client = Dropbox::API::Client.new(:token  =\u003e ACCESS_TOKEN, :secret =\u003e ACCESS_SECRET)\n# The file is a Dropbox::API::File object, so you can call methods on it!\n@client.search('test.txt').each do |file|\n  file.copy(file.path + \".old2\")\nend\n```\n\nWhat differs this from the dropbox gem?\n--------------------------------------\n\nDropbox::API does not extend the Ruby primitives, like the dropbox gem:\n\nhttps://github.com/RISCfuture/dropbox/tree/master/lib/dropbox/extensions\n\nDropbox::API::Client methods\n----------------------------\n\n### Dropbox::API::Client#account\n\nReturns a simple object with information about the account:\n\n```ruby\nclient.account # =\u003e #\u003cDropbox::API::Object\u003e\n```\n\nFor more info, see [https://www.dropbox.com/developers/reference/api#account-info](https://www.dropbox.com/developers/reference/api#account-info)\n\n### Dropbox::API::Client#find\n\nWhen provided a path, returns a single file or directory\n\n```ruby\nclient.find 'file.txt' # =\u003e #\u003cDropbox::API::File\u003e\n```\n\n### Dropbox::API::Client#destroy\n\nRemoves the file specified by path\n\nReturns a Dropbox::API::File object of the deleted file\n\n```ruby\nclient.destroy 'file.txt' # =\u003e #\u003cDropbox::API::File\u003e\n```\n\n### Dropbox::API::Client#ls\n\nWhen provided a path, returns a list of files or directories within that path\n\nBy default it's the root path:\n\n```ruby\nclient.ls # =\u003e [#\u003cDropbox::API::File\u003e, #\u003cDropbox::API::Dir\u003e]\n```\n\nBut you can provide your own path:\n\n```ruby\nclient.ls 'somedir' # =\u003e [#\u003cDropbox::API::File\u003e, #\u003cDropbox::API::Dir\u003e]\n```\n\n### Dropbox::API::Client#mkdir\n\nCreates a new directory and returns a Dropbox::API::Dir object\n\n```ruby\nclient.mkdir 'new_dir' # =\u003e #\u003cDropbox::API::Dir\u003e\n```\n\n### Dropbox::API::Client#upload\n\nStores a file with a provided body under a provided name and returns a Dropbox::API::File object\n\n```ruby\nclient.upload 'file.txt', 'file body' # =\u003e #\u003cDropbox::API::File\u003e\n```\n\n### Dropbox::API::Client#chunked_upload\n\nStores a file from a File object under a provided name and returns a Dropbox::API::File object. It should be used for larger files.\n\n```ruby\nclient.chunked_upload 'file.txt', File.open('file.txt') # =\u003e #\u003cDropbox::API::File\u003e\n```\n\n### Dropbox::API::Client#download\n\nDownloads a file with a provided name and returns it's content\n\n```ruby\nclient.download 'file.txt' # =\u003e 'file body'\n```\n\n### Dropbox::API::Client#search\n\nWhen provided a pattern, returns a list of files or directories within that path\n\nBy default it searches the root path:\n\n```ruby\nclient.search 'pattern' # =\u003e [#\u003cDropbox::API::File\u003e, #\u003cDropbox::API::Dir\u003e]\n```\n\nHowever, you can specify your own path:\n\n```ruby\nclient.search 'pattern', :path =\u003e 'somedir' # =\u003e [#\u003cDropbox::API::File\u003e, #\u003cDropbox::API::Dir\u003e]\n```\n\n### Dropbox::API::Client#delta\n\nReturns a cursor and a list of files that have changed since the cursor was generated.\n\n```ruby\ndelta = client.delta 'abc123'\ndelta.cursor # =\u003e 'def456'\ndelta.entries # =\u003e [#\u003cDropbox::API::File\u003e, #\u003cDropbox::API::Dir\u003e]\n```\n\nWhen called without a cursor, it returns all the files.\n\n```ruby\ndelta = client.delta 'abc123'\ndelta.cursor # =\u003e 'abc123'\ndelta.entries # =\u003e [#\u003cDropbox::API::File\u003e, #\u003cDropbox::API::Dir\u003e]\n```\n\nOptionally, you can set additional parameters, e.g. **path_prefix**. You can find all available parameters in the [Dropbox API documentation](https://www.dropbox.com/developers/core/docs#delta).\n\n```ruby\ndelta = client.delta 'abc123', path_prefix: '/Path/To/My/Folder'\ndelta.cursor # =\u003e 'abc123'\ndelta.entries # =\u003e [#\u003cDropbox::API::File\u003e, #\u003cDropbox::API::Dir\u003e]\n```\n\n\nDropbox::API::File and Dropbox::API::Dir methods\n----------------------------\n\nThese methods are shared by Dropbox::API::File and Dropbox::API::Dir\n\n### Dropbox::API::File#copy | Dropbox::API::Dir#copy\n\nCopies a file/directory to a new specified filename\n\n```ruby\nfile.copy 'newfilename.txt' # =\u003e #\u003cDropbox::API::File\u003e\n```\n\n### Dropbox::API::File#move | Dropbox::API::Dir#move\n\nMoves a file/directory to a new specified filename\n\n```ruby\nfile.move 'newfilename.txt' # =\u003e #\u003cDropbox::API::File\u003e\n```\n\n### Dropbox::API::File#destroy | Dropbox::API::Dir#destroy\n\nDeletes a file/directory\n\n```ruby\nfile.destroy 'newfilename.txt' # =\u003e #\u003cDropbox::API::File\u003e\n```\n\n\nDropbox::API::File methods\n----------------------------\n\n### Dropbox::API::File#revisions\n\nReturns an Array of Dropbox::API::File objects with appropriate rev attribute\n\nFor more info, see [https://www.dropbox.com/developers/reference/api#revisions](https://www.dropbox.com/developers/reference/api#revisions)\n\n### Dropbox::API::File#restore\n\nRestores a file to a specific revision\n\nFor more info, see [https://www.dropbox.com/developers/reference/api#restore](https://www.dropbox.com/developers/reference/api#restore)\n\n### Dropbox::API::File#share_url\n\nReturns the link to a file page in Dropbox\n\nFor more info, see [https://www.dropbox.com/developers/reference/api#shares](https://www.dropbox.com/developers/reference/api#shares)\n\n### Dropbox::API::File#direct_url\n\nReturns the link to a file in Dropbox\n\nFor more info, see [https://www.dropbox.com/developers/reference/api#media](https://www.dropbox.com/developers/reference/api#media)\n\n### Dropbox::API::File#thumbnail\n\nReturns the thumbnail for an image\n\nFor more info, see [https://www.dropbox.com/developers/reference/api#thumbnail](https://www.dropbox.com/developers/reference/api#thumbnail)\n\n### Dropbox::API::File#download\n\nDownloads a file and returns it's content\n\n```ruby\nfile.download # =\u003e 'file body'\n```\n\nDropbox::API::Dir methods\n----------------------------\n\n### Dropbox::API::Dir#ls\n\nReturns a list of files or directorys within that directory\n\n```ruby\ndir.ls # =\u003e [#\u003cDropbox::API::File\u003e, #\u003cDropbox::API::Dir\u003e]\n```\n\nTesting\n---------\n\nIn order to run tests, you need to have an application created and authorized. Put all tokens in spec/connection.yml and you're good to go.\n\nCheck out spec/connection.sample.yml for an example.\n\n## Releasing new version of gem\n\n1. Update version in [lib/dropbox-api/version.rb](lib/dropbox-api/version.rb) and push to `master`\n2. Create new GitHub release with tag name starting with `v` and the version, for example `v1.0.0`\n3. Gem will be automatically built and pushed to rubygems.org with GitHub Action\n\n## Copyright and license\n\nCopyright 2011 Zendesk\n\nLicensed under the [Apache License, Version 2.0](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzendesk%2Fdropbox-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzendesk%2Fdropbox-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzendesk%2Fdropbox-api/lists"}