ceph API之PHP的客户端连接

 下载v2的SDK开发包http://pear.amazonwebservices.com/get/sdk-latest.zip

 

解压到目录下:

unzip sdk-latest.zip && cd sdk-latest

编辑sdk.class.php

vim sdk.class.php

第157和162行
        /**  
         * The state of SSL/HTTPS use.
         */
        public $use_ssl = false;   #修改属性 调用类时不使用https访问

        /**  
         * The state of SSL certificate verification.
         */
        public $ssl_verification = false;  #修改属性 调用类时不使用https访问
将他们全部改为false,如果为true你需要使用ssl来连接默认连接443端口,需要配置证书

编写一个测试php:

vim test.php

<?php
define('AWS_KEY', 'place access key here');
define('AWS_SECRET_KEY', 'place secret key here');
define('AWS_CANONICAL_ID', 'your DHO Username');
define('AWS_CANONICAL_NAME', 'Also your DHO Username!');
$HOST = 'cephcloud.com';   #这里可以使用域名和IP

// require the amazon sdk for php library
require_once 'xxxxx/sdk.class.php';   #修改路径 test需要调用sdk包里面的sdk.class.php

// Instantiate the S3 class and point it at the desired host
$Connection = new AmazonS3(array(
        'key' => 'xxxxxxxxxxxxx',    #连接密匙
        'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxx',  #接入密匙
      //  'canonical_id' => AWS_CANONICAL_ID,
      //  'canonical_name' => AWS_CANONICAL_NAME,
));
$Connection->set_hostname($HOST);
$Connection->allow_hostname_override(false);

// Set the S3 class to use objects.dreamhost.com/bucket
// instead of bucket.objects.dreamhost.com
$Connection->enable_path_style();


$ListResponse = $Connection->list_buckets();
$Buckets = $ListResponse->body->Buckets->Bucket;
foreach ($Buckets as $Bucket) {
        echo $Bucket->Name . "\t" . $Bucket->CreationDate . "\n";
}

结果输出:

查询出桶的信息

xxx_bucket	2018-01-12T01:29:56.261Z
xxx_bbbbb	2018-01-12T01:30:54.960Z
xxxxx_bucket	2018-01-12T01:30:32.134Z

  

 

转载于:https://www.cnblogs.com/kuku0223/p/8275451.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值