Use scenario one: Store pictures of the site and be accessible to anyone
1. Create a bucket with the same name as the domain name you want to bind.
For example, the root domain name is mysite.com, want to put all the pictures under pic.mysite.com, access time with pic.mysite.com/a.jpg can directly access, then the bucket name should be set to pic.mysite.com
This time you can upload files in the console, of course, do the actual application of the need to use his SDK to write programs to achieve the upload function.
We upload a a.jpg, the right side of the properties inside gives a link "https://s3-xxx.amazonaws.com/pic.mysite.com/a.jpg", XXX will be based on your S3
In the region and different, click into is inaccessible, will prompt no permissions.
2. Set the bucket permissions.
Click Edit Bucket policy Inside Properties > Permissions, which will have policy generator guide you how to write policy.
Here we need to allow anyone to access the image stored in the bucket, so set the GetObject permissions to everyone.
{ "Version": "2012-10-17", "Id": "Policy1434523265640", "Statement": [ { "Sid": "Stmt1434523262292", "Effect": "Allow", "Principal": "*", "Action": "S3:getobject", "Resource": "ARN:AWS:S3:::p ic.mysite.com/*" } ]}
This time to visit the front of the https://s3-xxx.amazonaws.com/pic.mysite.com/a.jpg, you can open it smoothly.
3. Set the domain name.
In fact http://pic.mysite.com.s3-xxx.amazonaws.com/a.jpg this link can also open the above picture, so just give pic.mysite.com set an alias CNAME " Pic.mysite.com.s3-xxx.amazonaws.com "is done.
Use Scenario two: hosting a static web site with S3
You can refer to this document:
Https://docs.aws.amazon.com/zh_cn/AmazonS3/latest/dev/website-hosting-custom-domain-walkthrough.html
AWS S3 Usage Summary