- Login to your aws account and go to s3 console. https://s3.console.aws.amazon.com/s3/home?region=us-east-2
- Create a bucket. I’ll create 2 buckets. One for public and the other for private.
3. I’ll create my private bucket first and I will set it to block all public access.
4. For the public bucket, the setup should look like below.
5. Now we have 2 buckets.
6. In the public bucket, click permission.
7. Copy the Granting read-only permission to an anonymous user code from https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-bucket-policies.html and put it in bucket policy.
8. For the private bucket, go to permission.
9. Copy the json format from https://docs.aws.amazon.com/AmazonS3/latest/userguide/ManageCorsUsing.html to the Cross-origin resource sharing (CORS).
10. In order that our laravel app have an access of both buckets, we need to go to IAM or Identity Access Manager then create a user. Click services located at the upper left corner, then search for IAM. Then add user.
11. Create user name then give the user a programmatic access type.
12. Click attach existing policies directly then check AmazonS3FullAccess. Just click next until the user will be created.
13. 1. We need to install composer package for amazon s3.
composer require league/flysystem-aws-s3-v3 ~1.0 - https://laravel.com/docs/5.1/filesystem
14. Copy access key id, secret access key and other aws info and place it in .env file.
15. In config/filesystem, it should look like below.
16. Now, try to upload in your laravel app.