Skip to content
Browse files

Initial updates for bulk object delete.

  • Loading branch information...
1 parent bdf2587 commit 005e5732a53d4c85fa110282003b2de98bc6d403 @xach committed Jan 12, 2012
Showing with 20 additions and 5 deletions.
  1. +4 −0 crypto.lisp
  2. +16 −5 interface.lisp
View
4 crypto.lisp
@@ -79,6 +79,10 @@
(defun file-md5/hex (file)
(ironclad:byte-array-to-hex-string (file-md5 file)))
+(defun vector-md5/b64 (vector)
+ (base64:usb8-array-to-base64-string
+ (ironclad:digest-sequence :md5 vector)))
+
(defun file-etag (file)
(format nil "\"~A\"" (file-md5/hex file)))
View
21 interface.lisp
@@ -459,14 +459,25 @@ constraint."
:bucket bucket
:key key)))
+(defun bulk-delete-document (keys)
+ (cxml:with-xml-output (cxml:make-octet-vector-sink)
+ (cxml:with-element "Delete"
+ (dolist (key keys)
+ (cxml:with-element "Object"
+ (cxml:with-element "Key"
+ (cxml:text key)))))))
+
(defun delete-objects (bucket keys &key
((:credentials *credentials*) *credentials*))
"Delete the objects in BUCKET identified by KEYS."
- (map nil
- (lambda (key)
- (delete-object bucket key))
- keys)
- (length keys))
+ (let* ((content (bulk-delete-document keys))
+ (md5 (vector-md5/b64 content)))
+ (submit-request (make-instance 'request
+ :method :post
+ :sub-resource "delete"
+ :bucket bucket
+ :content content
+ :content-md5 md5))))
(defun delete-all-objects (bucket &key
((:credentials *credentials*) *credentials*))

0 comments on commit 005e573

Please sign in to comment.
Something went wrong with that request. Please try again.