@rktaxali Remove the AWS_URL and AWS_ENDPOINT environment variables. Laravel (and Flysystem) will be able to build the necessary S3 URLs just fine from your bucket name and region.
Problem storing a file in AWS S3
In my Laravel 10 project, I am getting an error when I try to upload a file to my AWS S3 bucket using PutObject() I am using league/flysystem-aws-s3-v3 version 3.16. My .env configuration:
AWS_ACCESS_KEY_ID=AKIA23ECJXS3U3M****
AWS_SECRET_ACCESS_KEY=DnB8dkbIenoVeTOWVgBPi*******
AWS_DEFAULT_REGION=ca-central-1
AWS_BUCKET=silkweb-canada
AWS_URL=http://silkweb-canada.s3.ca-central-1.amazonaws.com
AWS_ENDPOINT=http://silkweb-canada.s3.ca-central-1.amazonaws.com
AWS_USE_PATH_STYLE_ENDPOINT=false
AWS_S3_SILKWEB_URL="https://silkweb-canada.s3.ca-central-1.amazonaws.com/"
My S3 configuration in filesystems.php
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => true,
],
When I upload a file using PutObject(), I get an error message:
<Error><Code>NoSuchBucket</Code><Message>The specified bucket does not exist</Mes (truncated...) NoSuchBucket (client): The specified bucket does not exist - <Error><Code>NoSuchBucket</Code><Message>The specified bucket does not exist</Message><BucketName>silkweb-canada.silkweb-canada</BucketName><RequestId>GSH4FZAJ51ZHXZ7W</RequestId><HostId>VYDGFBI1WRemHbgcfx6f4CRdcY1pwRr/kAwkupClBIhp5uu/ARRu+wchhMjAfWbiGu9RQDsavJI=</HostId></Error> at /var/www/vhosts/app.silkweb.ca/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php:196)
However, if I change ASW_URL and AWS_ENDPOINT from http to https, the error message changes to:
Unable to write file at location: client/temp/27. Error executing "PutObject" on "https://silkweb-canada.silkweb-canada.s3.ca-central-1.amazonaws.com/client/temp/27"; AWS HTTP error: cURL error 60: SSL: no alternative certificate subject name matches target host name 'silkweb-canada.silkweb-canada.s3.ca-central-1.amazonaws.com' (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://silkweb-canada.silkweb-canada.s3.ca-central-1.amazonaws.com/client/temp/27 {"userId":2,"exception":"[object] (League\Flysystem\UnableToWriteFile(code: 0): Unable to write file at location: client/temp/27. Error executing "PutObject" on "https://silkweb-canada.silkweb-canada.s3.ca-central-1.amazonaws.com/client/temp/27"; AWS HTTP error: cURL error 60: SSL: no alternative certificate subject name matches target host name 'silkweb-canada.silkweb-canada.s3.ca-central-1.amazonaws.com' (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://silkweb-canada.silkweb-canada.s3.ca-central-1.amazonaws.com/client/temp/27 at /var/www/vhosts/app.silkweb.ca/vendor/league/flysystem/src/UnableToWriteFile.php:24)
Notice that in this case, the bucket name appears twice in the url (https://silkweb-canada.silkweb-canada.s3.ca-central-1.amazonaws.com/client/temp/27) .
My first question: What is the syntax or correct procedure to define AWS_URL and AWS_ENDPOINT? and the second question: How to fix this issue?
Thanks
Please or to participate in this conversation.