Slide 1

Slide 1 text

« S3 Upload Demo » & more 2018.07.24 azPHP

Slide 2

Slide 2 text

Hello! I’m Jeremy Lindblom Software Architect at McGraw-Hill Education @jeremeamia on Twitter and GitHub 2

Slide 3

Slide 3 text

Uploading to S3 from PHP We will use the AWS SDK for PHP to upload a file to S3 also dive into the details about S3, AWS, the SDK, & Guzzle 3

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

AWS Has a BIG Problem Hint: It’s not their competition. ?

Slide 6

Slide 6 text

6 They’re BIG!

Slide 7

Slide 7 text

Over 100 different services spread across 18+ categories 7

Slide 8

Slide 8 text

Almost Everything Else Many of their services build on each other EC2 S3 8

Slide 9

Slide 9 text

❖ Regions ❖ Buckets ❖ Objects ❖ Keys ❖ ACLs S3 - Is “private” by default - Set to “public-read” for public access us-west-1

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

“ 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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

Place your screenshot here The Four Ways ◇ Superglobals + AWS SDK ◇ PSR-7 + AWS SDK ◇ PSR-7 + Flysystem ◇ PSR-7 + PostObject 13

Slide 14

Slide 14 text

14 goto the_code; https://github.com/jeremeamia/azphp-s3-upload-demo

Slide 15

Slide 15 text

Thanks! Any questions? You can find me at: ◇ @jeremeamia ◇ [email protected] 15

Slide 16

Slide 16 text

Resources ◇ https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/s3-presigned-post.html ◇ https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPOST.html#RESTObjectPOST-requests-examples ◇ https://fontawesome.com/ ◇ https://getbootstrap.com/ ◇ https://ngrok.com/ ◇ http://flysystem.thephpleague.com/docs/ 16

Slide 17

Slide 17 text

Credits ◇ Presentation template by SlidesCarnival 17