Browse files

Downloads finally work. Thanks to dakrone for putting hardcore effort…

… into getting this stuff working in clj-http.
  • Loading branch information...
1 parent e15c4d0 commit 56dd38fc497cb644075fc3d52751ea5aa37b338e @Raynes committed Nov 28, 2011
Showing with 9 additions and 5 deletions.
  1. +1 −1 project.clj
  2. +8 −4 src/tentacles/repos.clj
@@ -1,6 +1,6 @@
(defproject tentacles "0.1.0-SNAPSHOT"
:description "A library for working with the Github API."
:dependencies [[clojure "1.3.0"]
- [clj-http "0.2.5-SNAPSHOT"]
+ [clj-http "0.2.5"]
[cheshire "2.0.2"]
[slingshot "0.9.0"]])
@@ -209,7 +209,12 @@
[user repo id options]
(nil? (api-call :delete "repos/%s/%s/downloads/%s" [user repo id] options)))
-(defn download-resource [user repo path options]
+;; Github uploads are a two step process. First we get a download resource and then
+;; we use that to upload the file.
+(defn download-resource
+ "Get a download resource for a file you want to upload. This will be
+ passed to upload-file to actually upload your file."
+ [user repo path options]
(let [path (file path)]
(assoc (api-call :post "repos/%s/%s/downloads"
[user repo]
@@ -222,16 +227,15 @@
"Upload a file given a download resource obtained from download-resource."
(post (:s3_url resp)
- {:debug true
- :multipart [["key" (:path resp)]
+ {:multipart [["key" (:path resp)]
["acl" (:acl resp)]
["success_action_status" "201"]
["Filename" (:name resp)]
["AWSAccessKeyId" (:accesskeyid resp)]
["Policy" (:policy resp)]
["Signature" (:signature resp)]
["Content-Type" (:mime_type resp)]
- ["file" (file (:filepath resp))]]}))
+ ["file" (:filepath resp)]]}))
;; Repo Forks API

0 comments on commit 56dd38f

Please sign in to comment.