LISTING 1: Creating A New Bucket

1:	<cffunction name="putBucket" access="public" output="false" returntype="boolean" description="Creates a
 bucket.">
2:		<cfargument name="bucketName" type="string" required="yes">
3:
4:		<cfset var signature = "">
5:		<cfset var dateTimeString = GetHTTPTimeString(Now())>
6:
7:		<!--- Create a canonical string to send based on operation requested --->
8:		<cfset var cs = "PUT\n\ntext/html\n#dateTimeString#\n/#arguments.bucketName#">
9:
10:		<!--- Replace "\n" with "chr(10) to get a correct digest --->
11:		<cfset var fixedData = replace(cs,"\n","#chr(10)#","all")>
12:
13:		<!--- Calculate the hash of the information --->
14:		<cf_hmac hash_function="sha1" data="#fixedData#" key="#variables.secretAccessKey#">
15:
16:		<!--- fix the returned data to be a proper signature --->
17:		<cfset signature = ToBase64(binaryDecode(digest,"hex"))>
18:
19:		<!--- put the bucket via REST --->
20:		<cfhttp method="PUT" url="http://s3.amazonaws.com/#arguments.bucketName#" charset="utf-8">
21:			<cfhttpparam type="header" name="Content-Type" value="text/html">
22:			<cfhttpparam type="header" name="Date" value="#dateTimeString#">
23:			<cfhttpparam type="header" name="Authorization" value="AWS #variables.accessKeyId#:#signature#">
24:		</cfhttp>
25:
26:		<cfreturn true>
27:	</cffunction>

Listing 2: HTTP Create Bucket Request

PUT /[bucket-name] HTTP/1.0
Date: Wed, 08 Mar 2006 04:06:15 GMT
Authorization: AWS [aws-access-key-id]:[header-signature]
Host: s3.amazonaws.com