Skip to content

Instantly share code, notes, and snippets.

@Jeiwan
Created January 31, 2017 08:13
Show Gist options
  • Save Jeiwan/95eb61c9f740a0a2c1e12ba654731521 to your computer and use it in GitHub Desktop.
Save Jeiwan/95eb61c9f740a0a2c1e12ba654731521 to your computer and use it in GitHub Desktop.
S3 Object Tagging with Amazonica
(require '[amazonica.aws.s3 :as s3])
(import '[com.amazonaws.services.s3.model Tag ObjectTagging])
(def bucket "bucket")
(def kkey "key")
(def file (clojure.java.io/file "file"))
(defn tags->tagging [tags]
(->> tags
clojure.walk/stringify-keys
(map #(Tag. (-> % first .toString) (-> % last .toString)))
(ObjectTagging.)))
(s3/put-object :bucket-name bucket :key kkey :file file :tagging (tags->tagging {:delete true :save false}))
(s3/get-object-tagging :bucket-name bucket :key kkey)
(s3/set-object-tagging :bucket-name bucket :key kkey :tagging (tags->tagging {:delete false :save true}))
(s3/delete-object-tagging :bucket-name bucket :key kkey)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment