tags:

views:

81

answers:

2

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

A: 

Try this:

http://www.hiteshagrawal.com/amazon-s3-service/amazon-s3-services-create-buckets-using-php

Hope that helps.

Moo

Moo
Yeah, nice googling skills. This should be a comment.
The Pixel Developer
Why? The question is not exactly a difficult one, its not posing any true problem and is perfectly Google-able, so why shouldn't I answer a poor question with a perfectly valid answer from Google? Its not against the site guidelines, just your own opinion which you have wonderfully supplied us with.
Moo
+2  A: 

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...

Pascal MARTIN
So much to create a simple bucket??? Would it be done without any libs? I just asked for a few lines of PHP; I did know it required a whole lib.
iLWheels
Maybe you should've mentioned that in your question? And what's wrong with a library?
ceejayoz
I suppose you could just use curl and do all the work yourself -- but why reinvent the wheel and not use some already-existing class ? *(And by "reinventing the wheel" I don't only mean "coding", but also testing, debugging, ...)*
Pascal MARTIN
Well, I love wheels that's why I'm called iLWheels. But curl would be cool, yeah. ;)
iLWheels
I don't like wheels when it means more work :-p ;;; and if you want more work, why ask for some already existing piece of code ? you "just" have to go digg through Amazon's API and start coding ;-) *(That that I don't say that in a bad way : I love coding too ^^ )*
Pascal MARTIN
Yep, same here ^^ I just wanted to have a look at how it's done without having to digg thru any horrible lib.
iLWheels