September 27th, 2008

ZS3 is a Common Lisp library for working with Amazon S3

I've just published ZS3, a Common Lisp library for working with Amazon S3. I wrote it to support the Alzheimer's Art Quilt Initiative virtual patch generator, which stores the patches on S3.

I first tried using CL-S3, but I couldn't get it working on SBCL for binary file uploads. There were some workarounds possible, but it seemed like starting from scratch might work better for me.

ZS3 has been tested and works fine on SBCL, Clozure CL, Allegro CL, and LispWorks CL. It doesn't work on CLISP due to a Gray stream issue; I haven't been able to figure out the problem. CLISP debuggers welcome! I haven't tested it on other Common Lisps, so I'd love to hear if it works or doesn't work elsewhere. Update The patch linked here does the trick on CLISP.

It should install fine with asdf-install. It's also available from git.xach.com.

To give you a general idea of what it can do, here's the defpackage form:

(defpackage #:zs3
  (:use #:cl)
  ;; Credentials
  (:export #:*credentials*
           #:access-key
           #:secret-key
           #:file-credentials)
  ;; Buckets
  (:export #:all-buckets
           #:creation-date
           #:name
           #:all-keys
           #:bucket-exists-p
           #:create-bucket
           #:delete-bucket
           #:bucket-location)
  ;; Bucket queries
  (:export #:query-bucket
           #:continue-bucket-query
           #:bucket-name
           #:keys
           #:common-prefixes
           #:prefix
           #:marker
           #:delimiter
           #:truncatedp
           #:last-modified
           #:etag
           #:size
           #:owner)
  ;; Objects
  (:export #:get-object
           #:get-vector
           #:get-string
           #:get-file
           #:put-object
           #:put-vector
           #:put-string
           #:put-file
           #:copy-object
           #:delete-object
           #:delete-objects
           #:delete-all-objects
           #:object-metadata)
  ;; Access Control
  (:export #:get-acl
           #:put-acl
           #:grant
           #:acl-eqv
           #:*all-users*
           #:*aws-users*
           #:*log-delivery*
           #:acl-email
           #:acl-person
           #:me
           #:make-public
           #:make-private)
  ;; Logging
  (:export #:enable-logging-to
           #:disable-logging-to
           #:enable-logging
           #:disable-logging
           #:logging-setup)
  ;; Misc.
  (:export #:*use-ssl*
           #:make-post-policy
           #:head
           #:authorized-url
           #:resource-url)
  ;; Util
  (:export #:octet-vector
           #:now+
           #:now-
           #:file-etag
           #:parameters-alist
           #:clear-redirects)
  (:shadow #:method))

For the full scoop, check out the full documentation.

This would have been much more difficult to write, portably, without the great (and portable) libraries Drakma, Closure XML, and Ironclad.