我正在運行Coldfusion8
,並正在使用嘗試使用EU存儲桶進行設置。如何使用Coldfusion在Amazon S3上創建一個EU桶?
我可以使用cfc在美國設置桶,但每當我更改爲EU設置時,它都不起作用。
這裏是正在使用的功能:
<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>
我已經加入了切換到歐盟地區的網址,但是這也不管用。
任何想法,我需要做什麼,才能在歐盟創建一個桶?
編輯:
我有固定的區域值。它仍然無法正常工作艱難,因爲如果我通過比""
以外的區域價值,這條線:
<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>
會產生strXML像這樣:
<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><LocationConstraint>#arguments.storageLocation#</LocationConstraint></CreateBucketConfiguration>
,再次創造了bad request
錯誤
你說這是行不通的,但實際上發生了什麼?你的'PUT'請求的返回值是什麼? – 2012-08-10 13:25:03
現在我正在發佈這個函數:bucketName = _my_bucket_&acl = public-read&storage = eu-west-1&createBucket = Create + Bucket。當表單發佈到自身時,頁面將重新加載,並且新的存儲桶不會顯示在頁面列表中(在AWS控制檯上都不會顯示)。我在哪裏可以找到來自放置請求的返回值? – frequent 2012-08-10 13:30:46
在您發佈的方法中發出'cfhttp'請求後,添加' '並查看來自Amazon的響應。這應該告訴你爲什麼亞馬遜決定不創建你的存儲桶。 –
2012-08-10 14:36:48