本文整理汇总了PHP中S3Request::setParameter方法的典型用法代码示例。如果您正苦于以下问题:PHP S3Request::setParameter方法的具体用法?PHP S3Request::setParameter怎么用?PHP S3Request::setParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类S3Request
的用法示例。
在下文中一共展示了S3Request::setParameter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAccessControlPolicy
/**
* Get object or bucket Access Control Policy
*
* @param string $bucket Bucket name
* @param string $uri Object URI
* @return mixed | false
*/
public static function getAccessControlPolicy($bucket, $uri = '')
{
$rest = new S3Request('GET', $bucket, $uri, self::$endpoint);
$rest->setParameter('acl', null);
$rest = $rest->getResponse();
if ($rest->error === false && $rest->code !== 200) {
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
}
if ($rest->error !== false) {
self::__triggerError(sprintf("S3::getAccessControlPolicy({$bucket}, {$uri}): [%s] %s", $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
return false;
}
$acp = array();
if (isset($rest->body->Owner, $rest->body->Owner->ID, $rest->body->Owner->DisplayName)) {
$acp['owner'] = array('id' => (string) $rest->body->Owner->ID, 'name' => (string) $rest->body->Owner->DisplayName);
}
if (isset($rest->body->AccessControlList)) {
$acp['acl'] = array();
foreach ($rest->body->AccessControlList->Grant as $grant) {
foreach ($grant->Grantee as $grantee) {
if (isset($grantee->ID, $grantee->DisplayName)) {
// CanonicalUser
$acp['acl'][] = array('type' => 'CanonicalUser', 'id' => (string) $grantee->ID, 'name' => (string) $grantee->DisplayName, 'permission' => (string) $grant->Permission);
} elseif (isset($grantee->EmailAddress)) {
// AmazonCustomerByEmail
$acp['acl'][] = array('type' => 'AmazonCustomerByEmail', 'email' => (string) $grantee->EmailAddress, 'permission' => (string) $grant->Permission);
} elseif (isset($grantee->URI)) {
// Group
$acp['acl'][] = array('type' => 'Group', 'uri' => (string) $grantee->URI, 'permission' => (string) $grant->Permission);
} else {
continue;
}
}
}
}
return $acp;
}
示例2: getBucketLocation
public static function getBucketLocation($bucket)
{
$rest = new S3Request('GET', $bucket, '');
$rest->setParameter('location', null);
$rest = $rest->getResponse();
if ($rest->error !== false || $rest->code !== 200) {
throw new Exception(sprintf("S3::getBucketLocation(%s): [%s] %s", $bucket, $rest->code, 'Unexpected HTTP status'));
}
return isset($rest->body[0]) && (string) $rest->body[0] !== '' ? (string) $rest->body[0] : 'US';
}
示例3: bucket_contents
/**
* Gets the contents of a bucket
*
* @param $bucket
* @param $prefix
* @param $marker
* @param $maxKeys
* @param $delimiter
* @return unknown_type
*/
public function bucket_contents($bucket, $prefix = null, $marker = null, $maxKeys = null, $delimiter = null)
{
$rest = new S3Request($this->id,$this->secret,true,'GET', $bucket, '');
if ($prefix !== null && $prefix !== '')
$rest->setParameter('prefix', $prefix);
if ($marker !== null && $marker !== '')
$rest->setParameter('marker', $marker);
if ($maxKeys !== null && $maxKeys !== '')
$rest->setParameter('max-keys', $maxKeys);
if ($delimiter !== null && $delimiter !== '')
$rest->setParameter('delimiter', $delimiter);
$response = $rest->getResponse();
if ($response->error === false && $response->code !== 200)
$response->error = array('code' => $response->code, 'message' => 'Unexpected HTTP status');
if ($response->error !== false)
throw new AWSException(sprintf("S3::getBucket(): [%s] %s", $response->error['code'], $response->error['message']));
$results = array();
$lastMarker = null;
if (isset($response->body, $response->body->Contents))
foreach ($response->body->Contents as $c)
{
$results[(string)$c->Key] = array(
'name' => (string)$c->Key,
'time' => strtotime((string)$c->LastModified),
'size' => (int)$c->Size,
'hash' => substr((string)$c->ETag, 1, -1)
);
$lastMarker = (string)$c->Key;
//$response->body->IsTruncated = 'true'; break;
}
if (isset($response->body->IsTruncated) && (string)$response->body->IsTruncated == 'false')
return $results;
// Loop through truncated results if maxKeys isn't specified
if ($maxKeys == null && $lastMarker !== null && (string)$response->body->IsTruncated == 'true')
do
{
$rest = new S3Request($this->id,$this->secret,true,'GET', $bucket, '');
if ($prefix !== null)
$rest->setParameter('prefix', $prefix);
$rest->setParameter('marker', $lastMarker);
if (($response = $rest->getResponse(true)) == false || $response->code !== 200)
break;
if (isset($response->body, $response->body->Contents))
foreach ($response->body->Contents as $c)
{
$results[(string)$c->Key] = array(
'name' => (string)$c->Key,
'time' => strtotime((string)$c->LastModified),
'size' => (int)$c->Size,
'hash' => substr((string)$c->ETag, 1, -1)
);
$lastMarker = (string)$c->Key;
}
}
while ($response !== false && (string)$response->body->IsTruncated == 'true');
return $results;
}
示例4: getBucket
public static function getBucket($bucket, $prefix = null, $marker = null, $maxKeys = null)
{
$rest = new S3Request('GET', $bucket, '');
if ($prefix !== null && $prefix !== '') {
$rest->setParameter('prefix', $prefix);
}
if ($marker !== null && $prefix !== '') {
$rest->setParameter('marker', $marker);
}
if ($maxKeys !== null && $prefix !== '') {
$rest->setParameter('max-keys', $maxKeys);
}
$response = $rest->getResponse();
if ($response->error === false && $response->code !== 200) {
$response->error = array('code' => $response->code, 'message' => 'Unexpected HTTP status');
}
if ($response->error !== false) {
trigger_error(sprintf("S3::getBucket(): [%s] %s", $response->error['code'], $response->error['message']), E_USER_WARNING);
return false;
}
$results = array();
$lastMarker = null;
if (isset($response->body, $response->body->Contents)) {
foreach ($response->body->Contents as $c) {
$results[(string) $c->Key] = array('name' => (string) $c->Key, 'time' => strToTime((string) $c->LastModified), 'size' => (int) $c->Size, 'hash' => substr((string) $c->ETag, 1, -1));
$lastMarker = (string) $c->Key;
//$response->body->IsTruncated = 'true'; break;
}
}
if (isset($response->body->IsTruncated) && (string) $response->body->IsTruncated == 'false') {
return $results;
}
// Loop through truncated results if maxKeys isn't specified
if ($maxKeys == null && $lastMarker !== null && (string) $response->body->IsTruncated == 'true') {
do {
$rest = new S3Request('GET', $bucket, '');
if ($prefix !== null) {
$rest->setParameter('prefix', $prefix);
}
$rest->setParameter('marker', $lastMarker);
if (($response = $rest->getResponse(true)) == false || $response->code !== 200) {
break;
}
if (isset($response->body, $response->body->Contents)) {
foreach ($response->body->Contents as $c) {
$results[(string) $c->Key] = array('name' => (string) $c->Key, 'time' => strToTime((string) $c->LastModified), 'size' => (int) $c->Size, 'hash' => substr((string) $c->ETag, 1, -1));
$lastMarker = (string) $c->Key;
}
}
} while ($response !== false && (string) $response->body->IsTruncated == 'true');
}
return $results;
}
示例5: getAccessControlPolicy
/**
* Get object or bucket Access Control Policy
*
* Currently this will trigger an error if there is no ACL on an object (will fix soon)
*
* @param string $bucket Bucket name
* @param string $uri Object URI
* @return mixed | false
*/
public static function getAccessControlPolicy($bucket, $uri = '')
{
$rest = new S3Request('GET', $bucket, $uri);
$rest->setParameter('acl', null);
$rest = $rest->getResponse();
if ($rest->error === false && $rest->code !== 200) {
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
}
if ($rest->error !== false) {
throw new S3Exception($rest->error['code'], "Could not get access control policy {$bucket}/{$uri}: " . $rest->error['message']);
return false;
}
$acp = array();
if (isset($rest->body->Owner, $rest->body->Owner->ID, $rest->body->Owner->DisplayName)) {
$acp['owner'] = array('id' => (string) $rest->body->Owner->ID, 'name' => (string) $rest->body->Owner->DisplayName);
}
if (isset($rest->body->AccessControlList)) {
$acp['acl'] = array();
foreach ($rest->body->AccessControlList->Grant as $grant) {
foreach ($grant->Grantee as $grantee) {
if (isset($grantee->ID, $grantee->DisplayName)) {
// CanonicalUser
$acp['acl'][] = array('type' => 'CanonicalUser', 'id' => (string) $grantee->ID, 'name' => (string) $grantee->DisplayName, 'permission' => (string) $grant->Permission);
} elseif (isset($grantee->EmailAddress)) {
// AmazonCustomerByEmail
$acp['acl'][] = array('type' => 'AmazonCustomerByEmail', 'email' => (string) $grantee->EmailAddress, 'permission' => (string) $grant->Permission);
} elseif (isset($grantee->URI)) {
// Group
$acp['acl'][] = array('type' => 'Group', 'uri' => (string) $grantee->URI, 'permission' => (string) $grant->Permission);
} else {
continue;
}
}
}
}
return $acp;
}