Zend Framework 101: Zend_Service_Amazon_S3
Connecting to Amazon S3
Now that you have an AWS Key and an AWS Secret Key you can connect to Amazon S3. To access Amazon S3 with the Zend Framework you will be using the class
Zend_Service_Amazon_S3
.
For the purposes of this article we'll assume your AWS Key is stored in a variable called
$awsKey
, and your AWS Secret Key is stored in a variable called $awsSecretKey
. The following example shows how to specify your keys each time you instantiate the class.
Listing 1 Instantiating Zend_Service_Amazon_S3 with keys (listing-1.php)
require_once('Zend/Service/Amazon/S3.php'); $s3 = new Zend_Service_Amazon_S3($awsKey, $awsSecretKey);
Listing 2 Specifying AWS keys ahead of time (listing-2.php)
require_once('Zend/Service/Amazon/S3.php'); Zend_Service_Amazon_S3::setKeys($awsKey, $awsSecretKey); $s3 = new Zend_Service_Amazon_S3(); $anotherS3 = new Zend_Service_Amazon_S3();
No comments:
Post a Comment