在PHP中的Aws s3对象权限更改不起作用

时间:2016-11-17 11:53:20

标签: php amazon-web-services amazon-s3 file-permissions

我正在寻找更改amazon aws s3中对象的权限。我曾多次尝试过。但它不起作用。我的文件权限是私有的,我想改为公开。我的代码如下。

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);
?>

但它显示输出

警告:S3 :: putBucket(testapp541):[BucketAlreadyOwnedByYou]您之前创建命名存储桶的请求已成功,您已拥有它。在第375行的D:\ xampp \ htdocs \ work \ aws \ s1 \ S3.php中 政策已更新

但它不会将权限更改为公开。

如何将权限更改为公开。请帮帮我。

0 个答案:

没有答案