How to write, read and delete text file on Amazon S3 Buckets using zend framework

Write sample.txt File:

 
      
require_once "./library/Zend/Service/Amazon/S3.php";



$s3 = new Zend_Service_Amazon_S3($awsKey, $awsSecret);



$perms = array(

 Zend_Service_Amazon_S3::S3_ACL_HEADER =>

  Zend_Service_Amazon_S3::S3_ACL_PUBLIC_READ

);

try

{

 //writing content to sample.txt file

 $ret = $s3->putObject(

  $bucketName . '/sample.txt',

  'Sample text content',

  $perms

 );

}

catch (Exception $e)

{

 echo $e->getMessage();          

} 

Read sample.txt file data from s3 bucket:

 
      
try

{ //read txt_content from txt file      

 $txt_content = $s3->getObject($bucketName . '/sample.txt');    

}

catch (Exception $e)

{

 echo $e->getMessage();

}

Delete text file:


try

{

 $ret = $s3->removeObject($bucketName. "/sample.txt");

}

catch (Exception $e)

{

 echo $e->getMessage();

}
How to write, read and delete text file on Amazon S3 Buckets using zend framework How to write, read and delete text file on Amazon S3 Buckets using zend framework Reviewed by Web Technology Funda on 10:19:00 PM Rating: 5

No comments

Free! Free!Free! Subscribe to Get Free PHP (Magento) tutorial Update in Your Inbox!!! Hurry Up!!!