Working with the Amazon S3 service is pretty easy if you understand the basic concepts of S3 and are using one of the AWS-provided SDKs, like the AWS SDK for PHP. This presentation and corresponding demo code will show you how it's done.
Tell me about “all the things”! Amazon S3 A blob storage cloud-based service provided by AWS. First released in 2006. Very popular, and has tons of features. Blob Storage A service for storing and retrieving “blob”s, or “object”s, which are essentially chunks of text or binary data. We typically call these “files” locally. AWS Amazon Web Services. A large suite of web services and APIs for manipulating data and infrastructure in Amazon’s cloud. AWS SDK for PHP An AWS-supported PHP library for interacting AWS’s services and APIs. It is built on Guzzle. Guzzle A popular HTTP client library for PHP that implements PSR-7 and middleware, and provides an abstraction layer over cURL. PSR-7 A PSR (PHP Standards Recommendation) created by the PHP-FIG to define standard interfaces for HTTP Request and Response objects. 4
Keys & Prefixes https://{bucket}.s3-{region}.amazonaws.com/{key} ◇ region: The AWS region (e.g., us-east-1, us-west-2) ◇ bucket: Your bucket name (they are globally unique) ◇ key: Path to the specific object in the bucket A prefix is the first part of a path key. Usually used to represent a “directory” (e.g., foo/bar/baz.json). When you list objects, you list them by a prefix. 10
“ Performance scales per prefix, so you can use as many prefixes as you need in parallel to achieve the required throughput. There are no limits to the number of prefixes. 11
Let’s Look at Some Code! We will look at four ways that an upload to S3 can be performed in a PHP application using the AWS SDK for PHP and other libraries. Demo