本文整理汇总了PHP中S3::getAccessControlPolicy方法的典型用法代码示例。如果您正苦于以下问题:PHP S3::getAccessControlPolicy方法的具体用法?PHP S3::getAccessControlPolicy怎么用?PHP S3::getAccessControlPolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类S3
的用法示例。
在下文中一共展示了S3::getAccessControlPolicy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: yss_s3_distribution
function yss_s3_distribution($type, $id)
{
global $ym_formgen, $yss_cloudfront, $yss_db, $wpdb;
// file details
$s3file = yss_get($id);
if ($_POST) {
// here we go
$distro = $_POST['distro'];
list($can, $oai, $bucket, $file, $domain, $type) = explode('|', $distro);
$packet = array('type' => 'CanonicalUser', 'id' => $can, 'name' => 'CloudFront Origin Access Identity ' . $oai, 'permission' => 'READ');
$acp = array();
require_once YSS_CLASSES_DIR . 'S3.php';
$s3 = new S3();
$s3->setAuth(get_option('yss_user_key'), get_option('yss_secret_key'));
//get existing and merge
$acp = $s3->getAccessControlPolicy($bucket, $file);
$acp['acl'][] = $packet;
if ($s3->setAccessControlPolicy($bucket, $file, $acp)) {
$acp = $s3->getAccessControlPolicy($bucket, $file);
// store
$distribution = json_decode($s3file->distribution);
if ($type == 'stream') {
$distribution->streaming = $domain;
} else {
$distribution->download = $domain;
}
$distribution = json_encode($distribution);
$sql = 'UPDATE ' . $yss_db . ' SET
distribution = \'' . $distribution . '\'
WHERE id = ' . $id;
$wpdb->query($sql);
echo '<div id="message" class="updated"><p>Permissions updated</p></div>';
yss_s3_list();
return;
} else {
echo '<div id="message" class="error"><p>Permissions update failed</p></div>';
}
}
if ($type == 'stream') {
$data = $yss_cloudfront->get_streaming();
} else {
$data = $yss_cloudfront->get_distribution();
}
if (is_array($data)) {
$test = array_keys($data);
if ($test[0] != '0') {
$data = array($data);
}
}
if (is_array($data)) {
echo ym_box_top('Deploy');
echo '
<form action="" method="post">
<fieldset>
<p>You can select a distribution to expose the file, ' . $s3file->bucket . '/' . $s3file->resource_path . ' onto</p>
<table class="form-table">
';
$items = array('blank' => 'Select');
foreach ($data as $item) {
$bucket = $item['S3Origin']['DNSName']['value'];
list($bucket, $null) = explode('.', $bucket, 2);
$enabled = $item['Enabled']['value'];
if ($enabled == 'true' && $s3file->bucket == $bucket) {
// Distribution is enabled and is for this bucket matches
$status = $item['Status']['value'];
$domain = $item['DomainName']['value'];
$oai = $item['S3Origin']['OriginAccessIdentity']['value'];
list($null, $nulm, $oai) = explode('/', $oai);
// oai needs canonical
$canonical = $yss_cloudfront->get_oai_canonical($oai);
$value = $canonical . '|' . $oai . '|' . $bucket . '|' . $s3file->resource_path . '|' . $domain . '|' . $type;
//echo '<option value="' . $value . '">' . $domain . '</option>';
$items[$value] = $domain;
}
}
$ym_formgen->render_combo_from_array_row('Distribution', 'distro', $items, '', 'Which Distribution to expose this file on');
echo '
</table>
<p class="submit">
<input type="submit" value="Deploy!" />
</p>
</fieldset>
</form>
';
echo ym_box_bottom();
} else {
echo '<div id="message" class="error"><p>Failed to load Distributions or none available</p></div>';
}
}
示例2: connectAndAuthorize
public static function connectAndAuthorize($key, $secret, $bucket, $email, $auth_type = 'FULL_CONTROL')
{
require_once CASH_PLATFORM_ROOT . '/lib/S3.php';
$s3_instance = new S3($key, $secret);
$bucket_exists = $s3_instance->getBucket($bucket);
if (!$bucket_exists) {
$bucket_exists = $s3_instance->putBucket($bucket);
}
if ($bucket_exists) {
$acp = $s3_instance->getAccessControlPolicy($bucket);
if (is_array($acp)) {
$acp['acl'][] = array('email' => $email, 'permission' => $auth_type);
return $s3_instance->setAccessControlPolicy($bucket, '', $acp);
} else {
return false;
}
}
}