本文整理汇总了PHP中Aws\S3\S3Client::execute方法的典型用法代码示例。如果您正苦于以下问题:PHP S3Client::execute方法的具体用法?PHP S3Client::execute怎么用?PHP S3Client::execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aws\S3\S3Client
的用法示例。
在下文中一共展示了S3Client::execute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBasicOperations
public function testBasicOperations()
{
$inputBucket = 'php-integ-transcoder-test-bucket-input';
$outputBucket = 'php-integ-transcoder-test-bucket-output';
$roleName = 'php-integ-transcoder-test-role';
$policyName = 'php-integ-transcoder-test-policy';
$pipelineName = 'php-integ-transcoder-test-pipeline';
self::log('Create input and output buckets for the Elastic Transcoder pipeline.');
$commands = array();
$commands[] = $this->s3->getCommand('CreateBucket', array('Bucket' => $inputBucket));
$commands[] = $this->s3->getCommand('CreateBucket', array('Bucket' => $outputBucket));
$this->s3->execute($commands);
self::log('Create an IAM Role for the Elastic Transcoder pipeline.');
$result = $this->iam->getCommand('CreateRole', array('RoleName' => $roleName, 'AssumeRolePolicyDocument' => self::DUMMY_IAM_POLICY_ASSUME_ROLE))->getResult();
$roleArn = $result->getPath('Role/Arn');
self::log('Put a policy on the IAM Role for the Elastic Transcoder pipeline.');
$result = $this->iam->getCommand('PutRolePolicy', array('PolicyName' => $policyName, 'RoleName' => $roleName, 'PolicyDocument' => self::DUMMY_IAM_POLICY_ALLOW_S3))->getResult();
self::log('Use TestRole to validate our pipeline inputs. NOTE: Ours are not valid on purpose.');
$result = $this->transcoder->getCommand('TestRole', array('InputBucket' => $inputBucket, 'OutputBucket' => $outputBucket, 'Role' => $roleArn, 'Topics' => array()))->getResult();
$this->assertEquals('false', $result['Success']);
self::log('Create an Elastic Transcoder pipeline.');
$result = $this->transcoder->getCommand('CreatePipeline', array('Name' => $pipelineName, 'InputBucket' => $inputBucket, 'OutputBucket' => $outputBucket, 'Role' => $roleArn, 'Notifications' => array_fill_keys(array('Progressing', 'Completed', 'Warning', 'Error'), '')))->getResult();
$pipelineId = $result->getPath('Pipeline/Id');
self::log('Make sure created Elastic Transcoder pipeline is in the list of pipelines.');
$result = $this->transcoder->getCommand('ListPipelines')->getResult();
$pipelineNames = $result->getPath('Pipelines/*/Name');
$this->assertContains($pipelineName, $pipelineNames);
self::log('Make sure ListPipelines iterator works.');
$found = false;
foreach ($this->transcoder->getIterator('ListPipelines') as $pipeline) {
if ($pipeline['Name'] == $pipelineName) {
$found = true;
break;
}
}
if (!$found) {
$this->fail('Did not find the pipeline in the iterator results.');
}
self::log('Make sure created Elastic Transcoder pipeline can be read.');
$result = $this->transcoder->getCommand('ReadPipeline', array('Id' => $pipelineId))->getResult();
$this->assertEquals($pipelineName, $result->getPath('Pipeline/Name'));
self::log('Delete the Elastic Transcoder pipeline.');
$response = $this->transcoder->getCommand('DeletePipeline', array('Id' => $pipelineId))->getResponse();
$this->assertEquals(202, $response->getStatusCode());
self::log('Delete the policy from the IAM Role for the Elastic Transcoder pipeline.');
$result = $this->iam->getCommand('DeleteRolePolicy', array('PolicyName' => $policyName, 'RoleName' => $roleName))->getResult();
self::log('Delete the IAM Role for the Elastic Transcoder pipeline.');
$result = $this->iam->getCommand('DeleteRole', array('RoleName' => $roleName))->getResult();
self::log('Delete the input and output buckets for the Elastic Transcoder pipeline.');
$commands = array();
$commands[] = $this->s3->getCommand('DeleteBucket', array('Bucket' => $inputBucket));
$commands[] = $this->s3->getCommand('DeleteBucket', array('Bucket' => $outputBucket));
$this->s3->execute($commands);
}
示例2: executeCommand
/**
* Executes a synchronous command.
*
* @param CommandInterface $command Command to execute.
*
* @return AwsS3Response
*/
protected function executeCommand(CommandInterface $command)
{
try {
$result = $this->client->execute($command);
} catch (AwsException $e) {
/* Return an error response. */
return new AwsS3Response(null, $e);
}
return new AwsS3Response($result, null);
}
示例3: getRawVisibility
/**
* Get the object acl presented as a visibility.
*
* @param string $path
*
* @return string
*/
protected function getRawVisibility($path)
{
$command = $this->s3Client->getCommand('getObjectAcl', ['Bucket' => $this->bucket, 'Key' => $this->applyPathPrefix($path)]);
$result = $this->s3Client->execute($command);
$visibility = AdapterInterface::VISIBILITY_PRIVATE;
foreach ($result->get('Grants') as $grant) {
if (isset($grant['Grantee']['URI']) && $grant['Grantee']['URI'] === self::PUBLIC_GRANT_URI && $grant['Permission'] === 'READ') {
$visibility = AdapterInterface::VISIBILITY_PUBLIC;
break;
}
}
return $visibility;
}
示例4: doesDirectoryExist
/**
* @param $location
*
* @return bool
*/
protected function doesDirectoryExist($location)
{
// Maybe this isn't an actual key, but a prefix.
// Do a prefix listing of objects to determine.
$command = $this->s3Client->getCommand('listObjects', ['Bucket' => $this->bucket, 'Prefix' => rtrim($location, '/') . '/', 'MaxKeys' => 1]);
try {
$result = $this->s3Client->execute($command);
return $result['Contents'] || $result['CommonPrefixes'];
} catch (S3Exception $e) {
if ($e->getStatusCode() === 403) {
return false;
}
throw $e;
}
}
示例5: saveFile
/**
* @param string $name
* @param string $data
* @return mixed
*/
public function saveFile($name, $data)
{
$command = $this->client->getCommand('PutObject', ['Bucket' => $this->getBucket(), 'Key' => $name, 'Body' => $data, 'ACL' => 'public-read']);
return $this->client->execute($command);
}