Ceph Object Gateway S3 API 介面有關問題PHP

來源:互聯網
上載者:User
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地址,你根據情況替換啊。
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.