Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...

When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Zend Framework 101: Zend_Service_Amazon_S3

Using Objects Stored in Amazon S3 Buckets

Finally, let's look at how other users can access files you store in your Amazon S3 buckets. The name of the bucket maps directly to the following domain name to the following web addresses:

  • http://[bucketName][objectName]

Using our previous examples from this article, you can access the my-file.txt file at the following URLs:


If we didn't set the permissions to be publicly readable, then it would not be possible for others to access your files.

You can now link to these files directly from your web pages, rather than hosting your files yourself. The following listing demonstrates how you might achieve this. It uses Amazon S3 for CSS, images, and for a file download link.

Listing 12 Using your Amazon S3 bucket on your web site (use-cdn.php)
    $bucketName = 'my-company-bucket';
    $cdnUrl = 'http://' . $bucketName . '';
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="" xml:lang="en" lang="en">
        <title>Sample Amazon S3 CDN Usage Page</title>
        <link rel="stylesheet"
              href="<?php echo $cdnUrl ?>/css/styles.css"
              media="all" />
            <img src="<?php echo $cdnUrl ?>/images/logo.png" alt="My Logo" />
            <a href="<?php echo $cdnUrl ?>/assets/profile.pdf">
                Download company profile

In This Article

Bonus listings: 2 available