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


PHP AmazonS3::list_buckets方法代码示例

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


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

示例1: execute

 protected function execute($arguments = array(), $options = array())
 {
     $this->configuration = ProjectConfiguration::getApplicationConfiguration($options['app'], $options['env'], true);
     // initialize the database connection
     //    $databaseManager = new sfDatabaseManager($this->configuration);
     //    $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     if (!sfConfig::get('app_sf_amazon_plugin_access_key', false)) {
         throw new sfException(sprintf('You have not set an amazon access key'));
     }
     if (!sfConfig::get('app_sf_amazon_plugin_secret_key', false)) {
         throw new sfException(sprintf('You have not set an amazon secret key'));
     }
     $s3 = new AmazonS3(sfConfig::get('app_sf_amazon_plugin_access_key'), sfConfig::get('app_sf_amazon_plugin_secret_key'));
     $response = $s3->list_buckets();
     if (!isset($response->body->Buckets->Bucket)) {
         throw new sfException($response->body->Message);
     }
     foreach ($response->body->Buckets->Bucket as $bucket) {
         $this->logSection(sprintf('%s', $bucket->Name), sprintf('created at "%s"', $bucket->Name, $bucket->CreationDate));
     }
 }
开发者ID:JoshuaEstes,项目名称:sfAmazonPlugin,代码行数:21,代码来源:s3ListbucketsTask.class.php

示例2: edit_ajax

 /**
  * @param string $args
  */
 public function edit_ajax($args = '')
 {
     $error = '';
     if (is_array($args)) {
         $ajax = FALSE;
     } else {
         if (!current_user_can('backwpup_jobs_edit')) {
             wp_die(-1);
         }
         check_ajax_referer('backwpup_ajax_nonce');
         $args['s3accesskey'] = $_POST['s3accesskey'];
         $args['s3secretkey'] = $_POST['s3secretkey'];
         $args['s3bucketselected'] = $_POST['s3bucketselected'];
         $args['s3base_url'] = $_POST['s3base_url'];
         $args['s3region'] = $_POST['s3region'];
         $ajax = TRUE;
     }
     echo '<span id="s3bucketerror" style="color:red;">';
     if (!empty($args['s3accesskey']) && !empty($args['s3secretkey'])) {
         try {
             $s3 = new AmazonS3(array('key' => $args['s3accesskey'], 'secret' => BackWPup_Encryption::decrypt($args['s3secretkey']), 'certificate_authority' => TRUE));
             $base_url = $this->get_s3_base_url($args['s3region'], $args['s3base_url']);
             if (stristr($base_url, 'amazonaws.com')) {
                 $s3->set_region(str_replace(array('http://', 'https://'), '', $base_url));
             } else {
                 $s3->set_hostname(str_replace(array('http://', 'https://'), '', $base_url));
                 $s3->allow_hostname_override(FALSE);
                 if (substr($base_url, -1) == '/') {
                     $s3->enable_path_style(TRUE);
                 }
             }
             if (stristr($base_url, 'http://')) {
                 $s3->disable_ssl();
             }
             $buckets = $s3->list_buckets();
         } catch (Exception $e) {
             $error = $e->getMessage();
         }
     }
     if (empty($args['s3accesskey'])) {
         _e('Missing access key!', 'backwpup');
     } elseif (empty($args['s3secretkey'])) {
         _e('Missing secret access key!', 'backwpup');
     } elseif (!empty($error) && $error == 'Access Denied') {
         echo '<input type="text" name="s3bucket" id="s3bucket" value="' . esc_attr($args['s3bucketselected']) . '" >';
     } elseif (!empty($error)) {
         echo esc_html($error);
     } elseif (!isset($buckets) || count($buckets->body->Buckets->Bucket) < 1) {
         _e('No bucket found!', 'backwpup');
     }
     echo '</span>';
     if (!empty($buckets->body->Buckets->Bucket)) {
         echo '<select name="s3bucket" id="s3bucket">';
         foreach ($buckets->body->Buckets->Bucket as $bucket) {
             echo "<option " . selected($args['s3bucketselected'], esc_attr($bucket->Name), FALSE) . ">" . esc_attr($bucket->Name) . "</option>";
         }
         echo '</select>';
     }
     if ($ajax) {
         die;
     }
 }
开发者ID:agileontheweb,项目名称:xvp,代码行数:65,代码来源:class-destination-s3-v1.php

示例3: backwpup_get_gstorage_buckets

function backwpup_get_gstorage_buckets($args = '')
{
    if (is_array($args)) {
        extract($args);
        $ajax = false;
    } else {
        check_ajax_referer('backwpupeditjob_ajax_nonce');
        if (!current_user_can(BACKWPUP_USER_CAPABILITY)) {
            die('-1');
        }
        $GStorageAccessKey = $_POST['GStorageAccessKey'];
        $GStorageSecret = $_POST['GStorageSecret'];
        $GStorageselected = $_POST['GStorageselected'];
        $ajax = true;
    }
    if (!class_exists('CFRuntime')) {
        require_once dirname(__FILE__) . '/../libs/aws/sdk.class.php';
    }
    if (empty($GStorageAccessKey)) {
        echo '<span id="GStorageBucket" style="color:red;">' . __('Missing access key!', 'backwpup') . '</span>';
        if ($ajax) {
            die;
        } else {
            return;
        }
    }
    if (empty($GStorageSecret)) {
        echo '<span id="GStorageBucket" style="color:red;">' . __('Missing secret access key!', 'backwpup') . '</span>';
        if ($ajax) {
            die;
        } else {
            return;
        }
    }
    try {
        $gstorage = new AmazonS3(array('key' => $GStorageAccessKey, 'secret' => $GStorageSecret, 'certificate_authority' => true));
        $gstorage->set_hostname('storage.googleapis.com');
        $gstorage->allow_hostname_override(false);
        $buckets = $gstorage->list_buckets();
    } catch (Exception $e) {
        echo '<span id="GStorageBucket" style="color:red;">' . $e->getMessage() . '</span>';
        if ($ajax) {
            die;
        } else {
            return;
        }
    }
    if ($buckets->status < 200 or $buckets->status >= 300) {
        echo '<span id="GStorageBucket" style="color:red;">' . $buckets->status . ': ' . $buckets->body->Message . '</span>';
        if ($ajax) {
            die;
        } else {
            return;
        }
    }
    if (count($buckets->body->Buckets->Bucket) < 1) {
        echo '<span id="GStorageBucket" style="color:red;">' . __('No bucket found!', 'backwpup') . '</span>';
        if ($ajax) {
            die;
        } else {
            return;
        }
    }
    echo '<select name="GStorageBucket" id="GStorageBucket">';
    foreach ($buckets->body->Buckets->Bucket as $bucket) {
        echo "<option " . selected(strtolower($GStorageselected), strtolower($bucket->Name), false) . ">" . $bucket->Name . "</option>";
    }
    echo '</select>';
    if ($ajax) {
        die;
    } else {
        return;
    }
}
开发者ID:hscale,项目名称:webento,代码行数:74,代码来源:func_backwpupeditjob.php


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