The way I'm uploading the image is the following:
$file = $request->featured_image;
$filename = time().'.'.$request->featured_image->extension();
$file->storeAs('images/', $filename, 's3');
$course = Course::create([
'featured_image' => $filename,
]);
The problem is when I tried to get it with blade:
<img src="{{Storage::disk('s3')->url($course->featured_image)}}" alt="course">
When I try to access the URL, I get something like
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>0W0NVXNHFRJY7MYP</RequestId>
<HostId>Xex73PhCOr1fm6cnhkDTOeqppblAYIrUtZ1jO81Jh3yjEhIHzvRcWsAg22VL5QrIoXcgefX6GTc=</HostId>
</Error>
For the permissions of AWS, I gave full access to S3. So I'm not sure why is this happening. The file DOES get saved.
It's probably because you have a private bucket, you can issue temporary URLs really easily though to get around this. (or open up the permissions on your bucket)
example:
Storage::disk('s3')->temporaryUrl($image, now()->addMinutes(30))