Home  >  Article  >  Backend Development  >  Ceph Object Gateway S3 API 接口有关问题PHP

Ceph Object Gateway S3 API 接口有关问题PHP

WBOY
WBOYOriginal
2016-06-13 12:11:111041browse

Ceph Object Gateway S3 API 接口问题PHP

<?php<br />define('AWS_KEY', '账号');<br />define('AWS_SECRET_KEY', '密码');<br />//define('AWS_CANONICAL_ID', 'your DHO Username');<br />//define('AWS_CANONICAL_NAME', 'Also your DHO Username!');<br />$HOST = 'IP';<br />// require the amazon sdk for php library<br />require_once 'sdk-1.6.2/sdk.class.php';<br /><br />// Instantiate the S3 class and point it at the desired host<br />$Connection = new AmazonS3(array(<br />        'key' => AWS_KEY,<br />        'secret' => AWS_SECRET_KEY,<br />        //'canonical_id' => AWS_CANONICAL_ID,<br />        //'canonical_name' => AWS_CANONICAL_NAME,<br />));<br />$Connection->set_hostname($HOST);<br />$Connection->allow_hostname_override(false);<br /><br />// Set the S3 class to use objects.dreamhost.com/bucket<br />// instead of bucket.objects.dreamhost.com<br />$Connection->enable_path_style();<br />echo "测试1";<br />$ListResponse = $Connection->list_buckets();<br />echo "测试2";<br />$Buckets = $ListResponse->body->Buckets->Bucket;<br />foreach ($Buckets as $Bucket) {<br />	echo $Bucket->Name . "\t" . $Bucket->CreationDate . "<br>";<br />}

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn