topical media & game development
mashup-delicious-11-delcache-create-s3-bucket.php / php
<?php
//uncomment if your PEAR path is different
#set_include_path(get_include_path() . PATH_SEPARATOR . "/usr/lib/php");
//your bucket name that must be unique throughout ALL s3 users
define('BUCKET_NAME','username_delcache');
//access and secret keys for your s3 account
define('S3_ACCESS_KEY','accesskey');
define('S3_SECRET_KEY','secretkey');
// pear installed goodness
require_once 'Crypt/HMAC.php';
require_once 'HTTP/Request.php';
//other settings
define('S3_URL',"http://s3.amazonaws.com/");
define('ACL_SETTING','public-read'); //this will let you browse to data
//the date and time in rfc 822
content_type = ''; //can be empty for creating a bucket but not later
//assemble your s3 signature
content_type."\n".hasher =& new Crypt_HMAC(S3_SECRET_KEY, "sha1");
hasher->hash(s3req =& new HTTP_Request(S3_URL . BUCKET_NAME."/");
s3req->addHeader("content-type", s3req->addHeader("Date", s3req->addHeader("x-amz-acl", ACL_SETTING);
signature);
s3req->getResponseCode()."\n";
function hex2b64(raw = '';
for (i < strlen(i+=2) {
str, raw);
}
?>
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.