I looking for changing the permission of object in amazon aws s3. I have tried several times. But it not working. My file permission is private and i want to change as public. My code is given below.
1.php
include('s3_config.php');
$uri = '147936871180.jpg';
if (($acp = S3::getAccessControlPolicy($bucket, $uri)) !== false) {
// Here you would modify the $acp array...
// For example, grant access to the S3 LogDelivery system:
$acp["acl"][] = array(
"type" => "Group", "uri" => "http://acs.amazonaws.com/groups/global/AllUsers", "permission" => "READ_ACP"
);
$acp["acl"][] = array(
"type" => "Group", "uri" => "http://acs.amazonaws.com/groups/global/AllUsers", "permission" => "WRITE_ACP"
);
// Then update the policy using the modified $acp array:
if (S3::setAccessControlPolicy($bucket, $uri, $acp)) {
echo "Policy updated";
}
}
?>
s3_config.php
<?php
// Bucket Name
$bucket="testapp1541";
if (!class_exists('S3'))require_once('S3.php');
//AWS access info
if (!defined('awsAccessKey')) define('awsAccessKey', 'AKIAJJJJJJJJJJGFNVPA');
if (!defined('awsSecretKey')) define('awsSecretKey', '8CiFyiqc7SguQq11111t2LPV289CyuCaMF2Uq');
$s3 = new S3(awsAccessKey, awsSecretKey);
$s3->putBucket($bucket, S3::ACL_PUBLIC_READ_WRITE);
?>
But it shows the output is
Warning: S3::putBucket(testapp541): [BucketAlreadyOwnedByYou] Your previous request to create the named bucket succeeded and you already own it. in D:\xampp\htdocs\work\aws\s1\S3.php on line 375 Policy updated
But it not change the permission as public.
How to change permission as public. Please help me.