当前位置: 首页>>代码示例>>PHP>>正文


PHP S3Client::doesBucketExist方法代码示例

本文整理汇总了PHP中Aws\S3\S3Client::doesBucketExist方法的典型用法代码示例。如果您正苦于以下问题:PHP S3Client::doesBucketExist方法的具体用法?PHP S3Client::doesBucketExist怎么用?PHP S3Client::doesBucketExist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Aws\S3\S3Client的用法示例。


在下文中一共展示了S3Client::doesBucketExist方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct($params)
 {
     if (!isset($params['key']) || !isset($params['secret']) || !isset($params['bucket'])) {
         throw new \Exception("Access Key, Secret and Bucket have to be configured.");
     }
     $this->id = 'amazon::' . $params['key'] . md5($params['secret']);
     $this->bucket = $params['bucket'];
     $scheme = $params['use_ssl'] === 'false' ? 'http' : 'https';
     $this->test = isset($params['test']);
     $this->timeout = !isset($params['timeout']) ? 15 : $params['timeout'];
     $params['region'] = !isset($params['region']) || $params['region'] === '' ? 'eu-west-1' : $params['region'];
     $params['hostname'] = !isset($params['hostname']) || $params['hostname'] === '' ? 's3.amazonaws.com' : $params['hostname'];
     if (!isset($params['port']) || $params['port'] === '') {
         $params['port'] = $params['use_ssl'] === 'false' ? 80 : 443;
     }
     $base_url = $scheme . '://' . $params['hostname'] . ':' . $params['port'] . '/';
     $this->connection = S3Client::factory(array('key' => $params['key'], 'secret' => $params['secret'], 'base_url' => $base_url, 'region' => $params['region']));
     if (!$this->connection->isValidBucketName($this->bucket)) {
         throw new \Exception("The configured bucket name is invalid.");
     }
     if (!$this->connection->doesBucketExist($this->bucket)) {
         try {
             $result = $this->connection->createBucket(array('Bucket' => $this->bucket));
             $this->connection->waitUntilBucketExists(array('Bucket' => $this->bucket, 'waiter.interval' => 1, 'waiter.max_attempts' => 15));
             $this->testTimeout();
         } catch (S3Exception $e) {
             \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR);
             throw new \Exception("Creation of bucket failed.");
         }
     }
     if (!$this->file_exists('.')) {
         $result = $this->connection->putObject(array('Bucket' => $this->bucket, 'Key' => '.', 'Body' => '', 'ContentType' => 'httpd/unix-directory', 'ContentLength' => 0));
         $this->testTimeout();
     }
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:35,代码来源:amazons3.php

示例2: buildBucket

 /**
  * Attempt to build a bucket (if it doesn't already exist).
  *
  * @param string $bucketName
  */
 protected function buildBucket($bucketName)
 {
     if (!$this->s3Client->doesBucketExist($bucketName, true)) {
         $this->s3Client->createBucket(['ACL' => $this->attachedFile->ACL, 'Bucket' => $bucketName, 'LocationConstraint' => $this->attachedFile->region]);
     }
     $this->bucketExists = true;
 }
开发者ID:a7madev,项目名称:stapler,代码行数:12,代码来源:S3.php

示例3: updateContainerProperties

 /**
  * Update a container with some properties
  *
  * @param string $container
  * @param array  $properties
  *
  * @throws DfException
  * @return void
  */
 public function updateContainerProperties($container, $properties = [])
 {
     $this->checkConnection();
     try {
         if ($this->blobConn->doesBucketExist($container)) {
             throw new \Exception("No container named '{$container}'");
         }
     } catch (\Exception $ex) {
         throw new DfException("Failed to update container '{$container}': " . $ex->getMessage());
     }
 }
开发者ID:pkdevboxy,项目名称:df-aws,代码行数:20,代码来源:S3FileSystem.php

示例4: testDeleteTrails

 /**
  * Execute the DescribeTrails and DeleteTrail operations
  *
  * @example Aws\CloudTrail\CloudTrailClient::deleteTrail
  * @example Aws\CloudTrail\CloudTrailClient::getDescribeTrailsIterator
  * @depends testStopLogging
  */
 public function testDeleteTrails($bucket)
 {
     $client = $this->cloudtrail;
     // @begin
     // List and delete all of the trails
     $trails = $client->getDescribeTrailsIterator();
     foreach ($trails as $trail) {
         $client->deleteTrail(array('Name' => $trail['Name']));
         echo "Deleted trail {$trail['Name']}.\n";
     }
     // @end
     $this->assertEquals("Deleted trail test-trail.\n", $this->getActualOutput());
     // Clean up test bucket
     sleep(5);
     if ($this->s3->doesBucketExist($bucket)) {
         $this->s3->clearBucket($bucket);
         $this->s3->deleteBucket(array('Bucket' => $bucket));
     }
 }
开发者ID:iLoiLohas,项目名称:pinchshopper,代码行数:26,代码来源:IntegrationTest.php

示例5: saveImage

 protected function saveImage(array $file, $subdirectory = '')
 {
     $s3 = new S3Client(['version' => 'latest', 'region' => 'eu-west-1']);
     $subdirectory = trim($subdirectory, '/');
     list($name, $extension) = explode('.', trim($file['name'], '/'));
     $filename = md5((string) rand()) . '.' . $extension;
     $directory = self::$public_image_directory . '/' . $subdirectory . '/';
     $bucket_name = 'comp3013';
     if (!$s3->doesBucketExist($bucket_name)) {
         echo 'Error, bucket didnt exist';
         exit(0);
     }
     while ($s3->doesObjectExist($bucket_name, $directory . $filename)) {
         $filename = md5((string) rand()) . '.' . $extension;
     }
     $parameters = ['ContentType' => $file['type'], 'Bucket' => $bucket_name, 'Key' => $directory . $filename, 'SourceFile' => $file['tmp_name']];
     print_r($parameters);
     $s3->putObject($parameters);
     $s3->waitUntil('ObjectExists', ['Bucket' => $bucket_name, 'Key' => $directory . $filename]);
     //exit(0);
     return 'http://comp3013.s3-website-eu-west-1.amazonaws.com/' . $directory . $filename;
 }
开发者ID:sampayne,项目名称:COMP3013,代码行数:22,代码来源:Creator.php

示例6: getConnection

	/**
	 * Returns the connection
	 *
	 * @return S3Client connected client
	 * @throws \Exception if connection could not be made
	 */
	public function getConnection() {
		if (!is_null($this->connection)) {
			return $this->connection;
		}

		$scheme = ($this->params['use_ssl'] === 'false') ? 'http' : 'https';
		$base_url = $scheme . '://' . $this->params['hostname'] . ':' . $this->params['port'] . '/';

		$this->connection = S3Client::factory(array(
			'key' => $this->params['key'],
			'secret' => $this->params['secret'],
			'base_url' => $base_url,
			'region' => $this->params['region']
		));

		if (!$this->connection->isValidBucketName($this->bucket)) {
			throw new \Exception("The configured bucket name is invalid.");
		}

		if (!$this->connection->doesBucketExist($this->bucket)) {
			try {
				$this->connection->createBucket(array(
					'Bucket' => $this->bucket
				));
				$this->connection->waitUntilBucketExists(array(
					'Bucket' => $this->bucket,
					'waiter.interval' => 1,
					'waiter.max_attempts' => 15
				));
				$this->testTimeout();
			} catch (S3Exception $e) {
				\OCP\Util::logException('files_external', $e);
				throw new \Exception('Creation of bucket failed. '.$e->getMessage());
			}
		}

		return $this->connection;
	}
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:44,代码来源:amazons3.php

示例7: validateBucketExists

 /**
  * Validate that a bucket exists.
  *
  * Since bucket names are global across all of S3, we can't determine if a
  * bucket doesn't exist at all, or if it exists but is owned by another S3
  * account.
  *
  * @param string $bucket
  *   The name of the bucket to test.
  * @param \Aws\S3\S3Client $client
  *   The S3Client to use.
  *
  * @throws S3ConnectValidationException
  *   Thrown when credentials are invalid or the bucket does not exist.
  */
 public static function validateBucketExists($bucket, \Aws\S3\S3Client $client)
 {
     if (!$client->doesBucketExist($bucket, FALSE)) {
         throw new S3ConnectValidationException('The S3 access credentials are invalid or the bucket does not exist.');
     }
 }
开发者ID:vuhoanglinh2002,项目名称:drupal,代码行数:21,代码来源:S3Client.php

示例8: doesBucketExist

 /**
  * Determines whether or not a bucket exists by name
  *
  * @param string $bucket The name of the bucket
  * @param bool   $accept403 Set to true if 403s are acceptable
  * @param array  $params Additional options to add to the executed command
  *
  * @return bool
  */
 public function doesBucketExist($bucket, $accept403 = true, array $params = [])
 {
     return $this->instance->doesBucketExist($bucket, $accept403, $params);
 }
开发者ID:Webiny,项目名称:Framework,代码行数:13,代码来源:S3.php

示例9: exist

 /**
  * exist
  *
  * @param boolean $accept403
  * @param array   $options
  *
  * @return boolean
  */
 public function exist($accept403 = true, array $options = array())
 {
     return $this->client->doesBucketExist($this->name, $accept403, $options);
 }
开发者ID:m6web,项目名称:aws-bundle,代码行数:12,代码来源:Bucket.php

示例10: verifyBucketExists

 protected function verifyBucketExists(S3Client $s3Client)
 {
     if (!strlen($this->bucketName)) {
         throw new Exception("[S3Sync::verifyBucketExists] Unable to verify S3 bucket: bucket name not set");
     }
     if (!$s3Client->doesBucketExist($this->bucketName)) {
         $result = $s3Client->createBucket(array('ACL' => 'private', 'Bucket' => $this->bucketName));
         $s3Client->waitUntilBucketExists(array('Bucket' => $this->bucketName));
         if (!$s3Client->doesBucketExist($this->bucketName)) {
             throw new Exception('[S3Sync::verifyBucketExists] Unable to create S3 bucket ' . $this->bucketName);
         }
     }
     return true;
 }
开发者ID:deno085,项目名称:s3-bulk-copy,代码行数:14,代码来源:S3Sync.php

示例11: _createBucket

 /**
  * _createBucket
  * Create the bucket, if not exists, for Amazon S3
  *
  * @param string $bucketName name of the bucket.
  * @return void
  */
 protected function _createBucket($bucketName)
 {
     //TODO: migliorare con un ritorno di qualcosa...
     if (!$this->_s3Client->doesBucketExist($bucketName)) {
         $this->_s3Client->createBucket(array('Bucket' => $bucketName));
     }
     // Poll the bucket until it is accessible
     $this->_s3Client->waitUntil('BucketExists', array('Bucket' => $bucketName));
 }
开发者ID:EnterpriseConsultingDeveloper,项目名称:cakephp-utils,代码行数:16,代码来源:UploadableBehavior.php

示例12: doesBucketExist

 public function doesBucketExist($bucket)
 {
     return $this->s3->doesBucketExist($bucket);
 }
开发者ID:TheJester12,项目名称:s3upload_field,代码行数:4,代码来源:class.s3Facade.php


注:本文中的Aws\S3\S3Client::doesBucketExist方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。