I am trying to show the acl of the bucket/object using s3.class.php.
but I am not getting any info from the s3, from which I can show the acl to read or edit.
I have cold fusion code to do this but I need to do this using php.
The cold fusion code is there:
<cffunction name="getBucketACL" access="public" output="false" returntype="any"
description="Gets the ACL of a bucket">
<cfargument name="bucketName" type="string" required="yes">
$var signature = "">
$var thisOwner = "">
$var thisGrantee = "">
$var data = "">
$var dateTimeString = GetHTTPTimeString(Now())>
<!--- Create a canonical string to send --->
$var cs = "GET\n\n\n#dateTimeString#\n/#urlencodedformat(arguments.bucketName)#/?acl">
<!--- Replace "\n" with "chr(10) to get a correct digest --->
$var fixedData = replace(cs,"\n","#chr(10)#","all")>
<!--- Calculate the hash of the information --->
<cf_hmac hash_function="sha1" data="#fixedData#" key="#variables.secretAccessKey#">
<!--- fix the returned data to be a proper signature --->
$signature = ToBase64(Hex2Bin("#digest#"))>
<cfhttp method="GET" url="http://s3.amazonaws.com/#urlencodedform ... ame)#/?acl">
<cfhttpparam type="header" name="Date" value="#dateTimeString#">
<cfhttpparam type="header" name="Authorization" value="AWS #variables.accessKeyId#:#signature#">
</cfhttp>
<cftry>
<cfif #cfhttp.statusCode# eq '200 OK'>
$data = xmlParse(cfhttp.FileContent)>
$users = structnew()>
$users["All Users"] = structnew()>
$users["All Users"].Group = 'Group'>
$users["All Users"].ID = 'http://acs.amazonaws.com/groups/global/AllUsers'>
$users["All Users"].full_control = FALSE>
$users["All Users"].write_acp = FALSE>
$users["All Users"].read_acp = FALSE>
$users["All Users"].write = FALSE>
$users["All Users"].read = FALSE>
$users["Authenticated Users"] = structnew()>
$users["Authenticated Users"].Group = 'Group'>
$users["Authenticated Users"].ID = 'http://acs.amazonaws.com/groups/global/ ... catedUsers'>
$users["Authenticated Users"].full_control = FALSE>
$users["Authenticated Users"].write_acp = FALSE>
$users["Authenticated Users"].read_acp = FALSE>
$users["Authenticated Users"].write = FALSE>
$users["Authenticated Users"].read = FALSE>
$grants = xmlSearch(data, "//:Grant")>
<cfloop index="x" from="1" to="#arrayLen(grants)#">
$grant = grants[x]>
<cfif isDefined("grant.Grantee.URI.xmltext") and #grant.Grantee.URI.xmltext# eq 'http://acs.amazonaws.com/groups/global/AllUsers'>
$users["All Users"].ID = '#grant.Grantee.URI.xmltext#'>
$users["All Users"].Group = 'Group'>
<cfif #grant.Permission.xmltext# eq 'FULL_CONTROL'>
$users["All Users"].full_control = TRUE>
$users["All Users"].write_acp = TRUE>
$users["All Users"].read_acp = TRUE>
$users["All Users"].write = TRUE>
$users["All Users"].read = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'WRITE_ACP'>
$users["All Users"].write_acp = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'READ_ACP'>
$users["All Users"].read_acp = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'WRITE'>
$users["All Users"].write = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'READ'>
$users["All Users"].read = TRUE>
</cfif>
<cfelseif isDefined("grant.Grantee.URI.xmltext") and #grant.Grantee.URI.xmltext# eq 'http://acs.amazonaws.com/groups/global/ ... catedUsers'>
$users["Authenticated Users"].ID = '#grant.Grantee.URI.xmltext#'>
$users["Authenticated Users"].Group = 'Group'>
<cfif #grant.Permission.xmltext# eq 'FULL_CONTROL'>
$users["Authenticated Users"].full_control = TRUE>
$users["Authenticated Users"].write_acp = TRUE>
$users["Authenticated Users"].read_acp = TRUE>
$users["Authenticated Users"].write = TRUE>
$users["Authenticated Users"].read = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'WRITE_ACP'>
$users["Authenticated Users"].write_acp = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'READ_ACP'>
$users["Authenticated Users"].read_acp = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'WRITE'>
$users["Authenticated Users"].write = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'READ'>
$users["Authenticated Users"].read = TRUE>
</cfif>
<cfelseif isDefined("grant.Grantee.ID.xmltext") and isDefined("grant.Grantee.DisplayName.xmltext")>
<cfif NOT StructKeyExists(users, "#grant.Grantee.DisplayName.xmltext#")>
$users["#grant.Grantee.DisplayName.xmltext#"] = structnew()>
$users["#grant.Grantee.DisplayName.xmltext#"].ID = "#grant.Grantee.ID.xmltext#">
$users["#grant.Grantee.DisplayName.xmltext#"].Group = 'CanonicalUser'>
$users["#grant.Grantee.DisplayName.xmltext#"].DisplayName = '#grant.Grantee.DisplayName.xmltext#'>
$users["#grant.Grantee.DisplayName.xmltext#"].full_control = FALSE>
$users["#grant.Grantee.DisplayName.xmltext#"].write_acp = FALSE>
$users["#grant.Grantee.DisplayName.xmltext#"].read_acp = FALSE>
$users["#grant.Grantee.DisplayName.xmltext#"].write = FALSE>
$users["#grant.Grantee.DisplayName.xmltext#"].read = FALSE>
</cfif>
<cfif #grant.Permission.xmltext# eq 'FULL_CONTROL'>
$users["#grant.Grantee.DisplayName.xmltext#"].full_control = TRUE>
$users["#grant.Grantee.DisplayName.xmltext#"].write_acp = TRUE>
$users["#grant.Grantee.DisplayName.xmltext#"].read_acp = TRUE>
$users["#grant.Grantee.DisplayName.xmltext#"].write = TRUE>
$users["#grant.Grantee.DisplayName.xmltext#"].read = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'WRITE_ACP'>
$users["#grant.Grantee.DisplayName.xmltext#"].write_acp = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'READ_ACP'>
$users["#grant.Grantee.DisplayName.xmltext#"].read_acp = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'WRITE'>
$users["#grant.Grantee.DisplayName.xmltext#"].write = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'READ'>
$users["#grant.Grantee.DisplayName.xmltext#"].read = TRUE>
</cfif>
<cfelse>
<cfif NOT StructKeyExists(users, "#grant.Grantee.EmailAddress.xmltext#")>
$users["#grant.Grantee.EmailAddress.xmltext#"] = structnew()>
$users["#grant.Grantee.EmailAddress.xmltext#"].ID = "#grant.Grantee.EmailAddress.xmltext#">
$users["#grant.Grantee.EmailAddress.xmltext#"].Group = 'AmazonCustomerByEmail'>
$users["#grant.Grantee.EmailAddress.xmltext#"].full_control = FALSE>
$users["#grant.Grantee.EmailAddress.xmltext#"].write_acp = FALSE>
$users["#grant.Grantee.EmailAddress.xmltext#"].read_acp = FALSE>
$users["#grant.Grantee.EmailAddress.xmltext#"].write = FALSE>
$users["#grant.Grantee.EmailAddress.xmltext#"].read = FALSE>
</cfif>
<cfif #grant.Permission.xmltext# eq 'FULL_CONTROL'>
$users["#grant.Grantee.EmailAddress.xmltext#"].full_control = TRUE>
$users["#grant.Grantee.EmailAddress.xmltext#"].write_acp = TRUE>
$users["#grant.Grantee.EmailAddress.xmltext#"].read_acp = TRUE>
$users["#grant.Grantee.EmailAddress.xmltext#"].write = TRUE>
$users["#grant.Grantee.EmailAddress.xmltext#"].read = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'WRITE_ACP'>
$users["#grant.Grantee.EmailAddress.xmltext#"].write_acp = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'READ_ACP'>
$users["#grant.Grantee.EmailAddress.xmltext#"].read_acp = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'WRITE'>
$users["#grant.Grantee.EmailAddress.xmltext#"].write = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'READ'>
$users["#grant.Grantee.EmailAddress.xmltext#"].read = TRUE>
</cfif>
</cfif>
</cfloop>
<!---<cfif isDefined("session.bucket_acl")>
$bucket_acl = #session.bucket_acl#>
<cfelse>
$bucket_acl = #structnew()#>
</cfif>
$bucket_acl[#hash(arguments.bucketName)#] = #structnew()#>
$bucket_acl[#hash(arguments.bucketName)#] = #users#>
$session.bucket_acl = #bucket_acl#>--->
<cfreturn users>
</cfif>
<cfcatch></cfcatch>
</cftry>
</cffunction>
How can I get the acl of a bucket/object
Moderator: General Moderators
-
vish_krish
- Forum Newbie
- Posts: 6
- Joined: Wed Mar 05, 2008 6:52 am