本文整理汇总了PHP中AmazonS3::get_bucket_list方法的典型用法代码示例。如果您正苦于以下问题:PHP AmazonS3::get_bucket_list方法的具体用法?PHP AmazonS3::get_bucket_list怎么用?PHP AmazonS3::get_bucket_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AmazonS3
的用法示例。
在下文中一共展示了AmazonS3::get_bucket_list方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: s3
/**
* Gets s3 object
*
* @param boolean $debug return error message instead of script stop
* @return \AmazonS3 s3 object
*/
public function s3($debug = false)
{
// This is workaround to composer autoloader
if (!class_exists('CFLoader')) {
throw new ClassNotFoundException('Amazon: autoload failed');
}
if (empty($this->_s3)) {
\CFCredentials::set(array('@default' => array('key' => $this->getOption('key'), 'secret' => $this->getOption('secret'))));
$this->_s3 = new \AmazonS3();
$this->_s3->use_ssl = false;
$this->_buckets = fn_array_combine($this->_s3->get_bucket_list(), true);
}
$message = '';
$bucket = $this->getOption('bucket');
if (empty($this->_buckets[$bucket])) {
$res = $this->_s3->create_bucket($bucket, $this->getOption('region'));
if ($res->isOK()) {
$res = $this->_s3->create_cors_config($bucket, array('cors_rule' => array(array('allowed_origin' => '*', 'allowed_method' => 'GET'))));
if ($res->isOK()) {
$this->_buckets[$bucket] = true;
} else {
$message = (string) $res->body->Message;
}
} else {
$message = (string) $res->body->Message;
}
}
if (!empty($message)) {
if ($debug == true) {
return $message;
}
throw new ExternalException('Amazon: ' . $message);
}
return $this->_s3;
}
示例2:
error_reporting(-1);
error_reporting(E_ALL);
ini_set('display_errors','on');
// Set plain text headers
header("Content-type: text/plain; charset=utf-8");
// Include the SDK
require_once '../sdk.class.php';
// $ec2 = new AmazonEC2();
//print_r ($ec2);
//print_r ($ec2->describe_instances());
// echo AWS_SECRET_KEY . " AND " . AWS_KEY;
$s3 = new AmazonS3();
//$response = $s3->get_bucket_list(); // Success?
//print_r($response);
//print_r ($s3->account_id);
//print_r ($s3);
//echo "GOT HERE!!";
$response = $s3->get_bucket_list();
print_r($response);
//var_dump($response->isOK());
示例3:
* list_buckets_page.php
*
* Generate a web page with a list of S3 buckets.
*
* Copyright 2009-2010 Amazon.com, Inc. or its affiliates. All Rights
* Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You
* may not use this file except in compliance with the License. A copy
* of the License is located at
*
* http://aws.amazon.com/apache2.0/
*
* or in the "license.txt" file accompanying this file. This file is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the
* License.
*/
error_reporting(E_ALL);
require_once 'sdk.class.php';
// Create the S3 access object
$s3 = new AmazonS3();
// Retrieve list of S3 buckets
$buckets = $s3->get_bucket_list();
// create a page header and an explanatory message
$output_title = 'Chapter 4 Sample - List of S3 Buckets';
$output_message = 'A simple HTML list of your S3 Buckets';
// Output the HTML
include 'include/list_buckets.html.php';
exit(0);