What does the method to upload a file look like?
Laravel 5.2 - Amazon S3 viewing uploaded file - AccessDenied
I am working with S3 and struggling to view an image after successfully uploading it. After uploading if I go into S3 I can see the file path etc but when I click on the link to view the file I get the following error:
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>1B6C94DCA39F6673</RequestId>
<HostId>
lrcpGOWch2LpGUWnkoIIUzAULqi1jgB8RV1lL6qyWe5k5t4BGImkndFdWJ2vTaS6mawN9POjyuw=
</HostId>
</Error>
This is the same error message as what I get in the network tab on chrome dev tools when I do
<img src="{{Storage::url('user/'.$user->id.'/profile_img/'.$user->profile_img)}}" alt="">
When I click the 'Make public' button on the object overview page the file then becomes available to view publicly.
I don't know much/anything about aws policies but followed this tutorial to create one that I needed for integration with Laravel.
https://wogan.blog/2017/01/04/use-amazon-s3-with-laravel-5/
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:ListAllMyBuckets",
"s3:GetBucketLocation"
],
"Resource": [
"arn:aws:s3:::bucket-name"
]
},
{
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:DeleteObject"
],
"Resource": [
"arn:aws:s3:::bucket-name/*"
]
}
]
}
Is there another policy that I need to allow all uploaded objects to be publicly viewable?
I also under Manage group permissions made Object access read and permissions access read but neither made the uploaded files publicly viewable.
Any help appreciated
Just to make sure did you install league/flysystem-aws-s3-v3 ~1.0 via composer??
And refer to this post https://laracasts.com/discuss/channels/laravel/l51-upload-file-to-aws-s3-using-filesystem-aws-permissions-problem-i-think?page=1
Please or to participate in this conversation.