Code Monkey home page Code Monkey logo

indaba-jopbox's Introduction

jopbox

jopbox is a Clojure library for working with the Dropbox API.

Demo

You can visit http://jopbox-demo.herokuapp.com/ for a demo web-app that uses jopbox. The source of the demo can be found here.

Installation

Add this to your project.clj's dependencies:

:dependencies [jopbox "0.2.0"]

Usage

Require jopbox from the REPL:

(use 'jopbox.client)

And before doing anything, you'll want to create a new Dropbox app here.

Authorization and Authentication

(def consumer (make-consumer API-KEY API-SECRET))
(def request-token (fetch-request-token consumer <callback-uri>))

Now, get the authorization URL:

(authorization-url consumer request-token)
;=> Visit the URL that this returns on your browser.

Then, get the access token response

(def access-token-response (fetch-access-token-response consumer request-token))

If you're using this with a web app, you probably want to use a callback URI to fetch the token response.

API methods

See Dropbox's API Reference for more information on these methods.

Account Info /account/info

(account-info consumer access-token-response)

File Metadata /metadata

(metadata consumer access-token-response :sandbox "video.flv")

Delta /delta

(delta consumer access-token-response <cursor>)

Media /media

(media consumer access-token-response :sandbox "video.flv")

Get File /files(GET)

(get-file consumer access-token-response :sandbox "foo.txt")
;; This works fine with plaintext files, but if you're dealing with something else you probably want to use /media.

Upload file /files_put

(upload-file consumer access-token-response :sandbox "foo.mp3" "/path/to/foo.mp3")

Running Tests

Create a file test/jopbox/dropbox_keys.clj with the following content:

(def dropbox-key "YOUR-API-KEY")
(def dropbox-secret "YOUR-API-SECRET")

Then, run lein test.

License

Copyright © 2013 Samrat Man Singh

Distributed under the Eclipse Public License, the same as Clojure.

indaba-jopbox's People

Contributors

samrat avatar erichmond avatar

Watchers

Jesse Chan-Norris avatar Joshua Miller avatar  avatar Steve Martocci avatar Ethan Fuchs avatar  avatar Adam Rokhsar avatar James Cloos avatar  avatar Andreas Klein avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.