I'm running Coldfusion8
and am using the Amazon S3 Rest Wrapper CFC trying to set it up with a EU bucket.
I can use the cfc to set up buckets in the US, but whenever I'm changing to the EU setting, it does not work.
Here is the function being used:
<cffunction name="putBucket" access="public" output="false" returntype="boolean" description="Creates a bucket.">
<cfargument name="bucketName" type="string" required="true">
<cfargument name="acl" type="string" required="false" default="public-read">
<cfargument name="storageLocation" type="string" required="false" default="">
<cfset var strXML = "">
<cfset var dateTimeString = GetHTTPTimeString(Now())>
<cfset var destination = "http://s3.amazonaws.com/">
<!--- Create a canonical string to send based on operation requested --->
<cfset var cs = "PUT\n\ntext/html\n#dateTimeString#\nx-amz-acl:#arguments.acl#\n/#arguments.bucketName#">
<cfset var signature = createSignature(cs)>
<!--- added switch to EU --->
<cfif arguments.storageLocation EQ "EU">
<cfset destination = "http://s3-eu-west-1.amazonaws.com/">
</cfif>
<!--- Create a proper signature --->
<cfif compare(arguments.storageLocation,'')>
<cfsavecontent variable="strXML">
<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><LocationConstraint>#arguments.storageLocation#</LocationConstraint></CreateBucketConfiguration>
</cfsavecontent>
<cfelse>
<cfset strXML = "">
</cfif>
<!--- put the bucket via REST --->
<cfhttp method="PUT" url="#destination##arguments.bucketName#" charset="utf-8">
<cfhttpparam type="header" name="Content-Type" value="text/html">
<cfhttpparam type="header" name="Date" value="#dateTimeString#">
<cfhttpparam type="header" name="x-amz-acl" value="#arguments.acl#">
<cfhttpparam type="header" name="Authorization" value="AWS #variables.accessKeyId#:#signature#">
<cfhttpparam type="body" value="#trim(strXML)#">
</cfhttp>
<cfreturn true>
</cffunction>
I have added the switch to the EU region URL, but this doesn't work either.
Any idea what I need to do in order to create a bucket in the EU?
EDIT:
I have fixed the regional values. It still doesn't work tough, because if I pass a regional value other than ""
, this line:
<cfif compare(arguments.storageLocation,'')>
<cfsavecontent variable="strXML">
<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><LocationConstraint>#arguments.storageLocation#</LocationConstraint></CreateBucketConfiguration>
</cfsavecontent>
<cfelse>
<cfset strXML = "">
</cfif>
will produce a strXML like so:
<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><LocationConstraint>#arguments.storageLocation#</LocationConstraint></CreateBucketConfiguration>
which creates the bad request
error again