-
Notifications
You must be signed in to change notification settings - Fork 4
S3 Demo
From the product page:
Amazon S3 stores data as objects within resources called "buckets". You can store as many objects as you want within a bucket, and write, read, and delete objects in your bucket. Objects can be up to 5 terabytes in size. You can control access to the bucket (who can create, delete, and retrieve objects in the bucket for example), view access logs for the bucket and its objects, and choose the AWS region where a bucket is stored to optimize for latency, minimize costs, or address regulatory requirements.
-
Ensure that you have populated these directives on the
.env
file:AWS_S3_BUCKET_NAME
AWS_S3_REGION
-
Run
php artisan config:clear
. -
Send a
POST
request to theaws/s3/upload
URI: -
A successful upload should give you an
ObjectURL
that you can check for yourself:(The default content disposition for S3 would be for files to download automatically and not display on the browser.)
-
Confirm that the file actually now exists on your S3 file system:
How do I allow/restrict other websites from displaying my S3-stored files (e.g. images).
You can configure Cross-Origin Resource Sharing (CORS) on individual buckets. This effectively prevents un-whitelisted hostnames from hotlinking and embedding your bucket resources. This way, only those who have been whitelisted can:
- Use your CSS stylesheets/JavaScripts
- Display your images
How do I want get more granular control over my bucket?
There are numerous guides about establishing bucket policies. Have a read at this official article from AWS.
Bucket policies can help you:
- Restrict access to specific IP addresses
- Restrict access to specific HTTP referrer
... and a lot more.
As seen on the Auckland AWS meetup.