コード例 #1
0
ファイル: Amazon.php プロジェクト: ambient-lounge/site
 /**
  * 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
0
ファイル: PHPPage.php プロジェクト: rakeshm/RakeshMPHPTest
	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
0
 * 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);