I am trying to change the access policy on an existing bucket. I am using 
Amazon S3 REST Wrapper by Joe Danziger. Using his cfc I can create, upload and 
delete buckets and objects - everything works! I added a function getACL() that 
will retrieve the ACL on a bucket (which works):

<cffunction name="getACL" access="public" output="false">
            
  <cfargument name="bucketName" type="string" required="yes">
                
  <cfset var dateTimeString = GetHTTPTimeString(Now())>

  <!--- Create a canonical string to send based on operation requested ---> 
  <cfset var cs = "GET\n\n\n#dateTimeString#\n/#arguments.bucketName#?acl"> 

  <!--- Create a proper signature --->
  <cfset var signature = createSignature(cs)>
  <cfhttp method="GET" url="http://s3.amazonaws.com/#arguments.bucketName#?acl";>
    <cfhttpparam type="header" name="Date" value="#dateTimeString#">
    <cfhttpparam type="header" name="Authorization" value="AWS 
variables.accessKeyId#:#signature#">
  </cfhttp>
                
  <cfreturn cfhttp.fileContent>
</cffunction>

Now I am trying to change the ACL:

<cffunction name="changeACL" access="public" output="false">
            
  <cfargument name="bucketName" type="string" required="yes">
  <cfargument name="acl" type="string" required="yes">
                
  <cfset var dateTimeString = GetHTTPTimeString(Now())>

<!--- Create a canonical string to send based on operation requested ---> 
  <cfset var cs = 
"PUT\n\n\n\x-amz-acl:#arguments.acl#\ntext/plain\n0\n#dateTimeString#\n#arguments.bucketName#?acl">
                                
<!--- Create a proper signature --->
  <cfset var signature = createSignature(cs)>
                
<cfhttp method="PUT" url="http://s3.amazonaws.com/#arguments.bucketName#?acl";>
<!--- x-amz-acl is private, public-read, public-read-write or 
authenticated-read --->
  <cfhttpparam type="header" name="x-amz-acl" value="#arguments.acl#">
  <cfhttpparam type="header" name="Content-Type" value="text/plain">
  <cfhttpparam type="header" name="Content-Length" value="0">
  <cfhttpparam type="header" name="Date" value="#dateTimeString#">
  <cfhttpparam type="header" name="Authorization" value="AWS 
#variables.accessKeyId#:#signature#">
</cfhttp>       
        
  <cfreturn cfhttp.fileContent> <!--- header --->
                  
</cffunction>

I keep getting an error saying the signatures don't match - I'm thinking that 
there's something wrong with the string "cs" not matching the header but I seem 
to be hitting a brick wall with this one.

Any ideas?

Andrew. 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:313044
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to