Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JC: Support vanilla multi-object delete #73

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src/aws/sdk/s3.clj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
com.amazonaws.services.s3.model.Grant
com.amazonaws.services.s3.model.CanonicalGrantee
com.amazonaws.services.s3.model.CopyObjectResult
com.amazonaws.services.s3.model.DeleteObjectsRequest
com.amazonaws.services.s3.model.DeleteObjectsResult
com.amazonaws.services.s3.model.DeleteObjectsResult$DeletedObject
com.amazonaws.services.s3.model.EmailAddressGrantee
com.amazonaws.services.s3.model.GetObjectRequest
com.amazonaws.services.s3.model.GetObjectMetadataRequest
Expand Down Expand Up @@ -343,7 +346,16 @@
:expiration-time (.getExpirationTime result)
:expiration-time-rule-id (.getExpirationTimeRuleId result)
:last-modified-date (.getLastModifiedDate result)
:server-side-encryption (.getServerSideEncryption result)}))
:server-side-encryption (.getServerSideEncryption result)})
DeleteObjectsResult
(to-map [result]
{:objects (map to-map (.getDeletedObjects result))})
DeleteObjectsResult$DeletedObject
(to-map [object]
{:delete-marker-version-id (.getDeleteMarkerVersionId object)
:delete-marker? (.isDeleteMarker object)
:key (.getKey object)
:version-id (.getVersionId object)}))

(defn get-object
"Get an object from an S3 bucket. The object is returned as a map with the
Expand Down Expand Up @@ -447,6 +459,16 @@
[cred bucket key]
(.deleteObject (s3-client cred) bucket key))

(defn delete-objects
"Delete objects from an S3 bucket. A optional map of options may be supplied.
Available options are:
:quiet - Suppress responses from S3"
[cred bucket keys & [{:keys [quiet]}]]
(let [request (-> (DeleteObjectsRequest. bucket)
(.withQuiet (boolean quiet))
(.withKeys (into-array keys)))] ; No AWS .setKeys(string...)
(to-map (.deleteObjects (s3-client cred) request))))

(defn object-exists?
"Returns true if an object exists in the supplied bucket and key."
[cred bucket key]
Expand Down