Skip to content

Commit

Permalink
Add key-seq
Browse files Browse the repository at this point in the history
Relates to weavejester#72
  • Loading branch information
drewr committed Jul 9, 2015
1 parent b01c0f1 commit 71f8cf8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 3 additions & 2 deletions project.clj
Expand Up @@ -3,7 +3,8 @@
:url "https://github.com/weavejester/clj-aws-s3"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.2.1"]
[com.amazonaws/aws-java-sdk "1.7.5"]
:dependencies [[org.clojure/clojure "1.7.0"]
[com.amazonaws/aws-java-sdk "1.7.5"
:exclusions [joda-time]]
[clj-time "0.6.0"]]
:plugins [[codox "0.8.10"]])
12 changes: 12 additions & 0 deletions src/aws/sdk/s3.clj
Expand Up @@ -442,6 +442,18 @@
(s3-client cred)
(map->ListObjectsRequest (merge {:bucket bucket} options)))))

(defn key-seq
"Return a seq of keys matching a bucket and prefix."
[cred bucket prefix]
(let [step (fn step [marker]
(let [r (list-objects cred bucket
{:prefix prefix :marker marker})]
(lazy-seq
(cons (->> r :objects (map :key))
(when (:truncated? r)
(step (:next-marker r)))))))]
(concat (step nil))))

(defn delete-object
"Delete an object from an S3 bucket."
[cred bucket key]
Expand Down

0 comments on commit 71f8cf8

Please sign in to comment.