Capture images using webcam and store it to Amazon S3 bucket.
-
Create simple web application which capture images and store it into local machine[As per our code it's look like this].
-
Open AWS consol and create IAM and S3 bucket
-
Create IAM user with programmatic access and save
ACCESS KEY
andSECRET ACCESS KEY
. -
Create s3 bucket.
-
Then click Bucket Policy.
-
Set your Bucket Policy to be the same as below. Change
User Arn
to be your User ARN. Also changeBucket Arn
to your Bucket ARN. The bucket ARN is above the textarea.{ "Version": "2012-10-17", "Id": "Policy1488494182833", "Statement": [ { "Sid": "Stmt1488493308547", "Effect": "Allow", "Principal": { "AWS": "User Arn" }, "Action": [ "s3:ListBucket", "s3:ListBucketVersions", "s3:GetBucketLocation", "s3:Get*", "s3:Put*" ], "Resource": "Bucket Arn" } ] } ```
-
Click CORS configuration and add the following policy:
<?xml version="1.0" encoding="UTF-8"?> <CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <CORSRule> <AllowedOrigin>*</AllowedOrigin> <AllowedMethod>GET</AllowedMethod> <AllowedMethod>POST</AllowedMethod> <AllowedMethod>PUT</AllowedMethod> <MaxAgeSeconds>3000</MaxAgeSeconds> <AllowedHeader>Authorization</AllowedHeader> </CORSRule> </CORSConfiguration>
-
Click on the New inline policy
-
Update the policy to be as follows:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:ListAllMyBuckets", "s3:PutObject", "s3:GetObject" ], "Resource": [ "arn:aws:s3:::*" ] } ] }
-
open
storeimage.php
-
-
Download aws-sdk for PHP and connect S3 bucket with web application.
- Download composer and intall it. (https://getcomposer.org/Composer-Setup.exe)
- Open root folder of your project and start cmd from location of that folder.
- Run below command to download and install aws-sdk for PHP.
composer require aws/aws-sdk-php
- Create EC2 instance and access it using SSH (https://github.com/UMANG2707/AWS-EC2-ACCESS-WITH-PUTTY).
- Download XAMPP server(https://dmsbilas.wordpress.com/2019/03/12/how-to-install-xampp-in-amazon-aws-ubuntu-linux/).
- Put this web application project into this instance and also install
aws-sdk for PHP
in root folder of project.