Created
October 26, 2012 21:10
-
-
Save emersonbroga/3961552 to your computer and use it in GitHub Desktop.
Amazon S3 Zend Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo '<pre style="background-color: #FFF; color:#000">'; | |
$s3Key = ''; | |
$s3Sectret = ''; | |
$imagePath = UPLOAD_PATH. DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR; | |
$fileName = 'barcode_2012090000110.jpg'; | |
$bucketName = $_SERVER['HTTP_HOST']; | |
$objectString = $bucketName.'/'.$fileName; | |
$s3 = new Zend_Service_Amazon_S3($s3Key, $s3Sectret); | |
$list = $s3->getBuckets(); | |
foreach($list as $bucket) { | |
echo "I have bucket $bucket<br/>"; | |
} | |
$s3->createBucket($bucketName); | |
$put = $s3->putFile($imagePath . $fileName, $objectString, | |
array(Zend_Service_Amazon_S3::S3_ACL_HEADER => | |
Zend_Service_Amazon_S3::S3_ACL_PUBLIC_READ)); | |
echo 'http://s3.amazonaws.com/'.$objectString; | |
echo '<br/>'; | |
die('Upload complete'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment