gpt4 book ai didi

php - 从 Laravel-5.7 在 S3 中上传文件时出现错误 AccessDenied

转载 作者:行者123 更新时间:2023-12-04 15:39:57 26 4
gpt4 key购买 nike

我在 上传 S3 服务器 上的任何文件时遇到问题。但相同的配置适用于不同的项目。没有改变概念,也没有改变任何配置。我正在开发 Laravel 5.8 版本。我正在共享代码和错误请告诉我它为什么会出现?

错误

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 a 403 Forbidden

AccessDeniedAccess 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')
],

在 S3 上上传

    $s3Path ="uploadFiles/pdf/2222222/2222222_COLLEGE_DETAILS_1569831261.pdf";     
$binary_data = base64_decode($file);
$pathS3 =Storage::disk('s3')->put($s3Path, $binary_data,'public');

最佳答案

我遇到这个问题是因为管理员在一个帐户上创建了多个存储桶。当他分成不同的帐户时,一切都开始工作。

另一种方法是检查您的存储桶访问权限(公共(public)/私有(private))。如果您的存储桶是私有(private)的,则从代码中删除 'public'

Storage::disk('s3')->put('path','file'); //code is like this.

关于php - 从 Laravel-5.7 在 S3 中上传文件时出现错误 AccessDenied,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58164281/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com