I resolved this by adding a CORS configuration in my bucket:
https://stackoverflow.com/questions/17533888/s3-access-control-allow-origin-header
Hi all,
I'm having some issues with utilising Amazon S3 with Nova Image fields and wondered if you could help me please.
Some current set-up information:
My filesystems.php config is set to point to my public disk and the code for that is:
'public' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
],
My Nova Image field is set-up as so:
Image::make('Photo URL', 'photo_url'),
I have also tried:
Image::make('Photo URL', 'photo_url')->disk('public'),
The problems I am facing are that when I upload an image or view an image the URL points to the S3 path, followed the full URL of my projects environment. e.g. https://XXX.s3.eu-west-2.amazonaws.com/https://myappurl.com/image.jpg thus issuing a 404 error
I have gone through the documentation and can't work it out. Is there any other steps I am missing?
To confirm, I don't have any problems storing or viewing outside of the Nova application.
Any help will be greatly appreciated.
Many Thanks, Jamie
@WORLDWEBDEVELOPMENT - I believe it's because photo_url in your case is a s3 temporary url...if photo_url is a custom accessor on your model like this:
public function getPhotoUrlAttribute()
{
return Storage::disk('s3')->temporaryUrl($this->s3_file_name, now()->addMinutes(30))
}
Then that's an issue, it needs to be an attribute that just returns $this->s3_file_name
If you want you can post your model where this field is coming from
Please or to participate in this conversation.