Reputation: 1906
I am facing problem while uploading any file on S3 Server. but the same configuration is working on a different project. No concept changed and no any configuration changed. I am working on Laravel 5.8 version. I am sharing code and Error please tell me why it is coming?
Error
Error executing "PutObject" on "https://coxxxxx.s3.ap-south-1.amazonaws.com/uploadFiles/pdf/2222222/2222222_COLLEGE_DETAILS_1569831261.pdf"; AWS HTTP error: Client error:
PUT https://colxxxxx.s3.ap-south-1.amazonaws.com/uploadFiles/pdf/2222222/2222222_COLLEGE_DETAILS_1569831261.pdf
resulted in a403 Forbidden
AccessDenied
Access Denied3E7C4E (truncated...) AccessDenied (client): Access Denied -
FileSysrems.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')
],
For Uplaod on S3
$s3Path ="uploadFiles/pdf/2222222/2222222_COLLEGE_DETAILS_1569831261.pdf";
$binary_data = base64_decode($file);
$pathS3 =Storage::disk('s3')->put($s3Path, $binary_data,'public');
Upvotes: 2
Views: 7051
Reputation: 1906
I was facing this problem because Admin created multiple buckets on a single account. when he divided into different account then everything starts working.
Another way is check your Bucket access ( Public / private). if your bucket is private then remove 'public' from code
Storage::disk('s3')->put('path','file'); //code is like this.
Upvotes: 4
Reputation: 740
Try changing accesses to your S3 bucket from IAM. It worked for me once I updated correct access.
Upvotes: 0