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


PHP Zend_Service_Amazon_S3::createBucket方法代码示例

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


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

示例1: isValid

 public function isValid($data)
 {
     $valid = parent::isValid($data);
     // Custom valid
     if ($valid) {
         // Check auth
         try {
             $testService = new Zend_Service_Amazon_S3($data['accessKey'], $data['secretKey'], $data['region']);
             $buckets = $testService->getBuckets();
         } catch (Exception $e) {
             $this->addError('Please double check your access keys.');
             return false;
         }
         // Check bucket
         try {
             if (!in_array($data['bucket'], $buckets)) {
                 if (!$testService->createBucket($data['bucket'], $data['region'])) {
                     throw new Exception('Could not create or find bucket');
                 }
             }
         } catch (Exception $e) {
             $this->addError('Bucket name is already taken and could not be created.');
             return false;
         }
     }
     return $valid;
 }
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:27,代码来源:S3.php

示例2: setUp

 /**
  * Sets up this test case
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     // Create the bucket here
     $s3 = new Zend_Service_Amazon_S3($this->_config->get(Zend_Cloud_StorageService_Adapter_S3::AWS_ACCESS_KEY), $this->_config->get(Zend_Cloud_StorageService_Adapter_S3::AWS_SECRET_KEY));
     $s3->createBucket($this->_config->get(Zend_Cloud_StorageService_Adapter_S3::BUCKET_NAME));
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:12,代码来源:S3Test.php

示例3: testVersionBucket

 /**
  * @see ZF-10219
  */
 public function testVersionBucket()
 {
     $this->_amazon->createBucket($this->_bucket);
     $response = $this->_amazon->_makeRequest('GET', $this->_bucket . '/?versions', array('versions' => ''));
     $this->assertNotNull($response, 'The response for the ?versions is empty');
     $xml = new SimpleXMLElement($response->getBody());
     $this->assertEquals((string) $xml->Name, $this->_bucket, 'The bucket name in XML response is not valid');
 }
开发者ID:omusico,项目名称:logica,代码行数:11,代码来源:OnlineTest.php

示例4: _createBucketIfNecessary

 protected function _createBucketIfNecessary()
 {
     if (!$this->_bucketExists) {
         if (!$this->_api->isBucketAvailable($this->_config['bucket'])) {
             $this->_api->createBucket($this->_config['bucket']);
         }
         $this->_bucketExists = true;
     }
 }
开发者ID:grrr-amsterdam,项目名称:garp3,代码行数:9,代码来源:S3.php

示例5: testCommonPrefixes

 public function testCommonPrefixes()
 {
     $this->_amazon->createBucket($this->_bucket);
     $this->_amazon->putObject($this->_bucket . '/test-folder/test1', 'test');
     $this->_amazon->putObject($this->_bucket . '/test-folder/test2-folder/', '');
     $params = array('prefix' => 'test-folder/', 'delimiter' => '/');
     $response = $this->_amazon->getObjectsAndPrefixesByBucket($this->_bucket, $params);
     $this->assertEquals($response['objects'][0], 'test-folder/test1');
     $this->assertEquals($response['prefixes'][0], 'test-folder/test2-folder/');
 }
开发者ID:navassouza,项目名称:zf2,代码行数:10,代码来源:OnlineTest.php

示例6: testGetObjectsByBucketParams

 /**
  *  @see ZF-7773
  */
 public function testGetObjectsByBucketParams()
 {
     $this->_amazon->createBucket("testgetobjectparams1");
     $this->_amazon->putObject("testgetobjectparams1/zftest1", "testdata");
     $this->_amazon->putObject("testgetobjectparams1/zftest2", "testdata");
     $list = $this->_amazon->getObjectsByBucket("testgetobjectparams1", array('max-keys' => 1));
     $this->assertEquals(1, count($list));
     $this->_amazon->removeObject("testgetobjectparams1/zftest1", "testdata");
     $this->_amazon->removeObject("testgetobjectparams1/zftest2", "testdata");
     $this->_amazon->removeBucket("testgetobjectparams1");
 }
开发者ID:vicfryzel,项目名称:zf,代码行数:14,代码来源:OnlineTest.php

示例7: basicProfileSave

 /** !!
  ************************************************************************
  * The following methods take the request data, validate it, parse it,
  * and store it if there were no previous errors.
  ************************************************************************
  */
 public function basicProfileSave($request_data)
 {
     global $error_msg;
     $thumb = null;
     $file_name = null;
     $file_mime_type = null;
     $file_size = null;
     $apiDataArray = array('person' => null);
     $this->isError = TRUE;
     if (empty($request_data['first_name'])) {
         $this->message = __('Fields marked with * can not be empty, First name can not be empty.');
     } else {
         if (!empty($request_data['pass']) || !empty($request_data['conpass'])) {
             $set_new_password = true;
             $new_password_ok = false;
             if ($request_data['pass'] != $request_data['conpass']) {
                 $this->message = __('Password and confirm password should match.');
             } else {
                 if (strlen($request_data['pass']) < PA::$password_min_length) {
                     $this->message = sprintf(__('Password should be of %s characters or more.'), PA::$password_min_length);
                 } else {
                     if (strlen($request_data['pass']) > PA::$password_max_length) {
                         $this->message = sprintf(__('Password should be less than %s charcaters.'), PA::$password_max_length);
                     } else {
                         // all is good
                         $new_password_ok = true;
                     }
                 }
             }
         }
     }
     if (isset($request_data['postal_code']) && isset($request_data['postal_code']['value']) && !empty($request_data['postal_code']['value'])) {
         $zipCode = trim($request_data['postal_code']['value']);
         $validator = new Zend_Validate_PostCode("en_US");
         if (!$validator->isValid($zipCode)) {
             $this->message = "The zip code is invalid.";
         } else {
             $request_data['postal_code']['value'] = $zipCode;
             $apiDataArray['person']['zip_code'] = $zipCode;
         }
     }
     if (isset($request_data['about']) && isset($request_data['about']['value']) && !empty($request_data['about']['value'])) {
         $about = trim($request_data['about']['value']);
         $validator = new Zend_Validate_StringLength(array('max' => 500));
         if (!$validator->isValid($about)) {
             $this->message = "The about field is limited to 500 characters. There are " . strlen($about) . " characters in the about field";
         }
     }
     if ($request_data['deletepicture'] == "true") {
         $this->handleDeleteUserPic($request_data);
     }
     /* Parag Jagdale - 10/27/2010: Upload files with Zend library, Resize files and upload to AmazonS3 */
     if (empty($this->message) && !empty($_FILES['userfile']['name'])) {
         $file = null;
         // Recieve uploaded file
         $zendUploadAdapter = new Zend_File_Transfer_Adapter_Http();
         $zendUploadAdapter->setDestination(PA::$upload_path);
         $zendUploadAdapter->addValidator('Size', false, '1MB')->addValidator('Count', false, 1)->addValidator('FilesSize', false, array('min' => '1kB', 'max' => '2MB'))->addValidator('Extension', false, array('jpeg', 'jpg', 'png', 'gif'))->addValidator('ImageSize', false, array('minwidth' => 40, 'maxwidth' => 1024, 'minheight' => 40, 'maxheight' => 768));
         if (!$zendUploadAdapter->isValid()) {
             // Invalid image, so show errors
             $this->message = __("The image you selected as your photo has some errors: <br />" . implode("<br />", $zendUploadAdapter->getMessages()));
         }
         try {
             $zendUploadAdapter->receive();
         } catch (Zend_File_Transfer_Exception $e) {
             $this->message = $e->getMessage();
         }
         if (empty($this->message)) {
             //If there is no error message then try saving to amazon s3
             // save images to amazon s3
             global $app;
             $aws_key = null;
             $aws_secret_key = null;
             $aws_key = $app->configData['configuration']['api_keys']['value']['amazon_aws_key']['value'];
             $aws_secret_key = $app->configData['configuration']['api_keys']['value']['amazon_aws_secret']['value'];
             $amazon_bucket_name = $app->configData['configuration']['api_keys']['value']['amazon_s3_bucket']['value'];
             if (isset($aws_key) && isset($aws_secret_key)) {
                 $s3 = null;
                 $bucketAvailable = false;
                 $bucketCreated = false;
                 $s3 = new Zend_Service_Amazon_S3($aws_key, $aws_secret_key);
                 if (isset($s3)) {
                     $bucketCreated = false;
                     $bucketAvailable = $s3->isBucketAvailable($amazon_bucket_name);
                     if (!$bucketAvailable) {
                         if ($s3->createBucket($amazon_bucket_name)) {
                             // new bucket was created
                             $bucketCreated = true;
                         }
                     } else {
                         $bucketCreated = true;
                     }
                     if ($bucketCreated == true) {
                         // delete old amazon s3 pictures
//.........这里部分代码省略.........
开发者ID:CivicCommons,项目名称:people-aggregator,代码行数:101,代码来源:EditProfileModule.php


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