Common Lisp Package: CL-S3

A Common Lisp Amazon S3 client interface package

README:

CL-S3

CL-S3 is a Common Lisp library that implements a client interface to the Amazon S3 Web Service.

More specifically, CL-S3

  • uses the Amazon S3 REST interface
  • does proper authorization
  • implements all S3 API calls with all options
  • parses the XML returned by some of the API
  • converts S3 error responses to proper Common Lisp condition objects
  • allows custom meta header (including canned access policies) and query parameters
  • does proper keep-alive processing (courtesy S-HTTP-CLIENT)
  • is portable over Common Lisp implementations (courtesy of S-SYSDEPS)
  • can optionally validate get and put object calls using MD5 hashing
  • contains 2 example higher level functions converting XML to simpler data
  • contains 2 example higher level functions for uploading and downloading files to and from S3
  • is properly packaged and has a documented public API
  • should be installed using ASDF

CL-S3 was written by Sven Van Caekenberghe and is available under an LLGPL license.

Please read the full Amazon S3 documentation and study the Common Lisp source code before contacting me with ;-)

There is an interesting post on Nicky Peeters' Blog showing how to get started using CL-S3.

FUNCTION

Public

DELETE-BUCKET (BUCKET-NAME)

Delete a bucket

DELETE-OBJECT (BUCKET-NAME OBJECT-KEY)

Delete the object identified by key in bucket

DOWNLOAD-FILE (BUCKET KEY &KEY DIR (IF-EXISTS SUPERSEDE) (ELEMENT-TYPE '(UNSIGNED-BYTE 8)))

Assuming key in bucket denotes a file, download it, optionally in dir

GET-BUCKET (BUCKET-NAME &KEY PREFIX MARKER MAX-KEYS DELIMITER)

List all keys in a bucket that satisfy a query

GET-OBJECT (BUCKET-NAME OBJECT-KEY &KEY CHECK-INTEGRITY BODY)

Retrieve the object identified by key in bucket

GET-SERVICE

List all available buckets

HEAD-OBJECT (BUCKET-NAME OBJECT-KEY)

Retrieve all meta-data for the the object identified by key in bucket

LISP-TIME->UNIX-TIME (S)

Convert from Common Lisp time to Unix time

LIST-BUCKETS

Returns a list of all accessible buckets' string names

LIST-OBJECTS (BUCKET-NAME &KEY PREFIX MARKER MAX-KEYS DELIMITER)

Return a list of all keys' strings in bucket, satifying the query

MAKE-AUTHORIZATION (VERB RESOURCE DATE &KEY (SECRET-ACCESS-KEY *SECRET-ACCESS-KEY*) CONTENT-MD5 CONTENT-TYPE AMZ-HEADERS)

Compute an Amazon S3 authorization signature

PUT-BUCKET (BUCKET-NAME)

Create a new bucket

PUT-OBJECT (BUCKET-NAME OBJECT-KEY CONTENT CONTENT-TYPE &KEY AMZ-HEADERS CHECK-INTEGRITY CONTENT-LENGTH)

Set the object identified by key in bucket to the specified content

REQUEST-DATE (&OPTIONAL (UNIVERSAL-TIME (GET-UNIVERSAL-TIME)))

Generate a GMT HTTP Request Date

UNIX-TIME->LISP-TIME (MS)

Convert from Unix time to Common Lisp time

UPLOAD-FILE (PATHNAME BUCKET &KEY NAME (ELEMENT-TYPE '(UNSIGNED-BYTE 8)) (MIME-TYPE application/octet-stream) ACL)

Upload the file at pathname under bucket, optionally storing it under name

Private

HMAC-SHA1 (DATA-STRING KEY-STRING)

Compute an RFC 2104 HMAC-SHA1 digest on data-string using key-string

MD5SUM-SEQUENCE (DATA-STRING)

Compute a MD5 digest on data-string

Undocumented

DO-S3-REQUEST (VERB URI &KEY CONTENT CONTENT-TYPE CONTENT-LENGTH CONTENT-MD5 AMZ-HEADERS QUERY BODY)

GENERIC-FUNCTION

Private

Undocumented

AMAZON-S3-API-ERROR-XML (CONDITION)

VARIABLE

Public

*ACCESS-KEY-ID*

The value of your Amazon Web Services public access key ID

*SECRET-ACCESS-KEY*

The value of your Amazon Web Services secret access key

Private

Undocumented

*AMAZON-HOST*

*S3-NS*

CONDITION

Public

AMAZON-S3-API-ERROR

Thrown when an Amazon S3 API Error is received

CONSTANT

Private

Undocumented

+ZERO-UNIX-TIME+