當前位置: 首頁>>代碼示例>>PHP>>正文


PHP S3Client::isValidBucketName方法代碼示例

本文整理匯總了PHP中Aws\S3\S3Client::isValidBucketName方法的典型用法代碼示例。如果您正苦於以下問題:PHP S3Client::isValidBucketName方法的具體用法?PHP S3Client::isValidBucketName怎麽用?PHP S3Client::isValidBucketName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Aws\S3\S3Client的用法示例。


在下文中一共展示了S3Client::isValidBucketName方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

示例3: isValidName

 /**
  * isValidName
  *
  * @return boolean
  */
 public function isValidName()
 {
     return S3Client::isValidBucketName($this->name);
 }
開發者ID:m6web,項目名稱:aws-bundle,代碼行數:9,代碼來源:Bucket.php


注:本文中的Aws\S3\S3Client::isValidBucketName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。