Skip to content

MAKE FILE PUBLIC #24

Open
isimpledesign opened this Issue Mar 9, 2012 · 0 comments

1 participant

@isimpledesign

Hi

I am trying to make all file in a bucket public so i can make the stream i am not able to do this with the following code.

<?php
if (!class_exists('S3')) require 's3/S3.php';

    // AWS access info
    if (!defined('awsAccessKey')) define('awsAccessKey', $as3key);
    if (!defined('awsSecretKey')) define('awsSecretKey', $assecretkey);

    $s3 = new S3(awsAccessKey, awsSecretKey);

    $bucket = ltrim($_POST['bucket']);
    $policy = ltrim($_POST['policy']);

    $s3->putBucket($bucket, S3::ACL_PUBLIC_READ);

    if (($contents = $s3->getBucket($bucket)) !== false) {

        foreach ($contents as $object) {

            $fname = $object['name'];

            if (($acp = S3::getAccessControlPolicy($bucket,$fname)) !== false) {

                echo "<pre>";
                print_r($acp);
                echo "</pre>";
            // 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/s3/LogDelivery", "permission" => "FULL_CONTROL"
            );
            // Then update the policy using the modified $acp array:
            if (S3::setAccessControlPolicy($bucket, $fname, $acp)) {
                echo $fname . "Policy updated";
            }
            }

        }

    }

?>

Can you help with this???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.