Amazon S3 region problem
Trying to upload an image to my S3 bucket results in:
Missing required client configuration options:
region: (string)
A "region" configuration value is required for the "s3" service
even though I provided the correct S3_REGION within .env and 'region' within filesystems.php. Is this a known problem?
UploadController
if($request->hasFile('avatar')){
$user = Auth::user();
$s3 = Storage::disk('s3');
$image = $request->file('avatar');
$filename = time() . '.' . $image->getClientOriginalExtension();
$s3 = Storage::putFile('uploads/user/avatars/', $request->file('avatar'), 'public');
Image::make($image)->resize(300,300)->save($s3);
$user->avatar = $filename;
$user->save();
}
Thank you in advance
What region name did you use?
Is your config cached? Try clearing it just in case as it might be using your old values.
AWS_KEY=AWSKEYVALUE
AWS_SECRET=AWSSECRETVALUE
AWS_REGION=us-west-2
AWS_BUCKET=bucket-name
I am using us-west-1/ Is their a difference between the use of AWS or S3 for key/secret/region and bucket ? @cronix
.env
S3_KEY=
S3_SECRET=
S3_REGION=
S3_BUCKET=
Error:
at ClientResolver->throwRequired(array('driver' => 's3', 'key' => null, 'secret' => null, 'region' => null, 'bucket' => null, 'version' => 'latest', 'service' => 's3', 'exception_class' => 'Aws\S3\Exception\S3Exception', 'config' => array(), 'scheme' => 'https'))
in ClientResolver.php (line 267)
@splendidkeen check your config/filesystems.php file to see which env values are being read.
@sutherland
'default' => env('FILESYSTEM_DRIVER', 'local'),
I guess this needs to be 's3'?
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
or should I change the driver to s3?
The disks section should have another entry for s3 like:
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => env('AWS_KEY'),
'secret' => env('AWS_SECRET'),
'region' => env('AWS_REGION'),
'bucket' => env('AWS_BUCKET'),
],
],
I already edited the filesystems s3 entry with all my credentials (IAM User key and secret) and the correct region, but it still shows this error
Error:
Missing required client configuration options:
region: (string)
A "region" configuration value is required for the "s3" service
(e.g., "us-west-2").
's3' => [
'driver' => 's3',
'key' => env('AWS_KEY'),
'secret' => env('AWS_SECRET'),
'region' => env('AWS_REGION'),
'bucket' => env('AWS_BUCKET'),
],
Please or to participate in this conversation.