Created
January 31, 2017 08:13
-
-
Save Jeiwan/95eb61c9f740a0a2c1e12ba654731521 to your computer and use it in GitHub Desktop.
S3 Object Tagging with Amazonica
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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