开发者

Could anyone show me how to create a bucket on Amazon S3 with PHP?

I'd love to see some code here rather than开发者_StackOverflow enjoy some sourse outside. =)


A solution could be to use the Zend_Service_Amazon_S3 component that's provided in Zend Framework -- if it's like many other components of ZF, it might be possible to use it outside of the framework, without having to do too much work to "extract" it.

I've never used it, but there are some examples of code on that manual page, and it doesn't seem too hard to use (quoting) :

require_once 'Zend/Service/Amazon/S3.php';

$s3 = new Zend_Service_Amazon_S3($my_aws_key, $my_aws_secret_key);
$s3->createBucket("my-own-bucket");
$s3->putObject("my-own-bucket/myobject", "somedata");
echo $s3->getObject("my-own-bucket/myobject");

(There are a couple of other examples I won't copy-paste)

An advantage of using a Zend Framework component is that ZF has (mostly) a good reputation, with code that's tested, maintained, supported, ...


Another solution could be to use this Amazon S3 PHP class ; I've never used it either, though...


<?php
require_once("sdk.class.php");
$s3 = new AmazonS3();
$bkt = (strtolower)$s3->key . "-bucket00";
$res = $s3->create_bucket($bkt, AmazonS3::REGION_US_E1);
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜