Beispiel #1
0
use Guzzle\Http\EntityBody;
use Obs\S3\Exception\S3Exception;
use Guzzle\Http\Message\Response;
function func($var)
{
    if (!$var) {
        $S3 = new S3Exception("hello word");
        $S3->setExceptionCode(400);
        $S3->setExceptionType("Client");
        $S3->setResponse(new Response(405));
        throw $S3;
    }
}
// 	$r = ObsClient::isValidBucketName("123");
// 	var_dump($r);
$client = ObsClient::factory(array('key' => 'C6840CE16E23C6F06EFF', 'secret' => 'RueC/EXFyvTbWGG6VkenF82w5pIAAAFNbiPG8EfN', 'endpoint' => 'http://129.7.182.2:5080', 'signature' => 's3'));
try {
    func(0);
} catch (S3Exception $e) {
    echo $e;
}
echo "--------------------------------\n";
//ssl认证
$client->setSslVerification(false, false, 0);
$resp = $client->listBuckets();
var_export($resp);
// 	$resp = $client->createBucket(array(
// 			'Bucket'=>'123456-2',
// 			'ACL'=>'log-delivery-write',
// 			'LocationConstraint'=>'abc'
// 	));
Beispiel #2
0
$bucket_name = '123456-10';
//桶名
$object_name = 'test';
//对象名
/****************************************************************************
 * 函数原型:public static function factory($config = array())				
 * 函数功能:初始化服务工厂													
 * 参数说明:key:AK值														
 * 			secret:SK值 													
 * 			endpoint:服务器地址,
 *          signature:s3,
 * 			path_style:是否使用绝对路径,取值 true or false
 *          region:登陆服务器的区域位置
 * 返回值:初始化服务句柄													
 ***************************************************************************/
$client = ObsClient::factory(array('key' => 'D2DE0CBCFF0BEFBE5712', 'secret' => 'KUaA754YVbcnRgP9ap12WsIcp8UAAAFN/wvvvvHL', 'endpoint' => 'http://129.7.182.2:80', 'signature' => 's3', 'path_style' => true, 'region' => 'mdc'));
/************************************************************************************
 * 函数原型:listBuckets()															
 * 函数功能:查询桶列表																
 * 参数说明:																		
 * 返回值:Buckets:查询桶信息列表,包含值(Name:桶名,CreationDate:创建时间)		
 * 		  Owner:桶拥有者信息,包含值(ID:拥有者用户ID,DisplayName:拥有者用户名)	
 * 		  RequestId:该消息的返回ID。												
 ***********************************************************************************/
function ListBuckets()
{
    global $client;
    echo "list bucket start...\n";
    try {
        $resp = $client->listBuckets();
        printf("RequestId:%s\n", $resp['RequestId']);