GithubHelp home page GithubHelp logo

wildhoney / clj-dropbox Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aria42/clj-dropbox

0.0 3.0 0.0 17 KB

Clojure bindings to the Dropbox API

Home Page: http://github.com/aria42/clj-dropbox

License: Eclipse Public License 1.0

Clojure 100.00%

clj-dropbox's Introduction

Clojure bindings to Dropbox API

clj-dropbox provides clojure bindings to the Dropbox API. In order to use this library, you need to at least setup as a Dropbox developer and get an OAuth conumser key. Instructions can be found here.

The library depends upon `clj-oauth' version 1.2.1 and which is in clojars.org.

Building

lein jar

Example

(require '[clj-dropbox.client :as dropbox])

; First you make a `consumer' which represents your 
; Dropbox  credientials you need to interact with Dropbox's OAuth. 
(def consumer (dropbox/new-consumer "my-developer-key" "my-developer-secret"))

; You need to do the OAuth dance in order
; to get the user-key and user-secret. You
; should persistently store these. 
(let [[authorization-url request-callback] 
	 (dropbox/request-user-authorization consumer my-callback-url)]
  ; User grants you access
  (println "Dear user authorize me at " authorization-url)
  ; After this is done and my-callback-url is pinged 
  ; (you can leave my-callback-url as  nil)
  (let [[user-key user-secret] (request-callback)]
    (println "I have user token info!")))  

; Once you have user-key and user-secret, make a client 
(def client (dropbox/new-user-client consumer user-key user-secret))

; Now you can do the fun stuff (see src/clj-dropbox/client.clj)

; Upload local file to dropbox
(dropbox/upload-file client "/path/to-local-file.txt" "dropbox-dir/")

; List files in root dropbox directory
; returns seq of file meta-data 
(dropbox/list-files client "")

; Get the contents of a file as a string
(dropbox/get-file client "tmp/my-great-idea.txt")

; If you want to do several operations with the same user
; on the same thread, you can save yourself the trouble
; of using the client argument everywhere
(dropbox/with-user (new-user-client consumer user-key user-secret)
  (doseq [[i f] (indexed (dropbox/list-files "")) 
	:when (= (-> f :path (.endsWith ".txt")))]
    (dropbox/copy-file (:path f) (str "my-text-files/txt-file-" i))))

Author

Aria Haghighi ([email protected])

My Website

Support

Email author with any issues.

Todo

  • Make SSL an option
  • Support creating an account
  • Support the OAuth-bypass Dropbox allows. Its dangerous though!
  • Fix any bugs I'm sure are in this.

License

Copyright (C) 2010 Aria Haghighi

Distributed under the Eclipse Public License, the same as Clojure uses. See the file License.

clj-dropbox's People

Contributors

wildhoney avatar

Watchers

 avatar  avatar  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.