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:
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.
$bucketName = 'my-company-bucket'; $cdnUrl = 'http://' . $bucketName . '.s3.amazonaws.com'; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Sample Amazon S3 CDN Usage Page</title> <link rel="stylesheet" href=" echo $cdnUrl /css/styles.css" type="text/css" media="all" /> </head> <body> <div> <img src=" echo $cdnUrl /images/logo.png" alt="My Logo" /> </div> <div> <a href=" echo $cdnUrl /assets/profile.pdf"> Download company profile </a> </div> </body> </html>