当前位置:Gxlcms > PHP教程 > CephObjectGatewayS3API接口有关问题PHP

CephObjectGatewayS3API接口有关问题PHP

时间:2021-07-01 10:21:17 帮助过:15人阅读

Ceph Object Gateway S3 API 接口问题PHP
define('AWS_KEY', '账号');
define('AWS_SECRET_KEY', '密码');
//define('AWS_CANONICAL_ID', 'your DHO Username');
//define('AWS_CANONICAL_NAME', 'Also your DHO Username!');
$HOST = 'IP';
// require the amazon sdk for php library
require_once 'sdk-1.6.2/sdk.class.php';

// Instantiate the S3 class and point it at the desired host
$Connection = new AmazonS3(array(
'key' => AWS_KEY,
'secret' => AWS_SECRET_KEY,
//'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();
echo "测试1";
$ListResponse = $Connection->list_buckets();
echo "测试2";
$Buckets = $ListResponse->body->Buckets->Bucket;
foreach ($Buckets as $Bucket) {
echo $Bucket->Name . "\t" . $Bucket->CreationDate . "
";
}

代码如上,HOST我用的是IP,因为没有域名,结果就是“测试2”那条语句不能输出,应该是$ListResponse = $Connection->list_buckets();有问题,具体可以看http://www.uinch.com/yun/oos-simple-demo.html,这里的作者是实现了的,但是用的同一个代码,我的就实现不了,是因为HOST必须用域名吗?
------解决思路----------------------
同求,对官方文档完全搞不清楚!!!!
------解决思路----------------------
楼主,你用的哪个OOS,只有ip是什么情况,是自己搭建的吗?
那个“oos.ctyunapi.cn”是天翼云的OOS地址,你根据情况替换啊。

人气教程排行