简体   繁体   English

执行“ GetObjectAcl”时出错,导致403禁止访问被拒绝

[英]Error executing “GetObjectAcl” resulted in a 403 Forbidden Access Denied

I am trying to copy an image from one folder to another one in Amazon S3 through Laravel 5.5 / PHP 7 我正在尝试通过Laravel 5.5 / PHP 7将图像从一个文件夹复制到Amazon S3中的另一个文件夹

$s3 = Storage::disk('s3');
$s3->copy('old_path/image.jpg', 'new_path/image.jpg');

And I am getting the error: 而且我得到了错误:

Aws \ S3 \ Exception \ S3Exception
Error executing "GetObjectAcl" on "https://mybucket.s3.us-east-2.amazonaws.com/old_path/image.jpg?acl"; AWS HTTP error: Client error: `GET https://mybucket.s3.us-east-2.amazonaws.com/old_path/image.jpg` resulted in a `403 Forbidden` response: <?xml version="1.0" encoding="UTF-8"?> <Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>xxx (truncated...) AccessDenied (client): Access Denied - <?xml version="1.0" encoding="UTF-8"?> <Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>xxx</RequestId><HostId>xxx</HostId></Error>

I've noticed that the query acl was automatically appended to old_path/image.jpg as you can see it shown in the error message https://mybucket.s3.us-east-2.amazonaws.com/old_path/image.jpg?acl , what I suspect it is causing the error, because the image is accessible through the URL https://mybucket.s3.us-east-2.amazonaws.com/old_path/image.jpg but it is inaccessible with the ?acl in its end. 我注意到查询acl已自动附加到old_path/image.jpg ,您可以在错误消息https://mybucket.s3.us-east-2.amazonaws.com/old_path/image.jpg?acl看到它https://mybucket.s3.us-east-2.amazonaws.com/old_path/image.jpg?acl ,我怀疑这是导致错误的原因,因为可以通过URL https://mybucket.s3.us-east-2.amazonaws.com/old_path/image.jpg访问该图像,但不能通过该访问?acl结束。

I don't know how to solve it. 我不知道该怎么解决。 Any idea?! 任何想法?!

Normally that appears when your Bucket-ACL is not correct. 通常,当您的Bucket-ACL不正确时会出现。 Your user has not enough permissions to get the object ACL. 您的用户没有足够的权限来获取对象ACL。 You have to generate a proper Bucket policy and insert it to your Bucket. 您必须生成适当的存储桶策略并将其插入到存储桶中。

You can use the generator to create a policy. 您可以使用生成器来创建策略。 If you have one you can extend them. 如果您有一个,则可以扩展它们。

https://docs.aws.amazon.com/AmazonS3/latest/user-guide/add-bucket-policy.html https://docs.aws.amazon.com/AmazonS3/latest/user-guide/add-bucket-policy.html

Sometimes it's a bit complicated to set the correct permissions for a defined user and you have to try it a bit. 有时,为已定义的用户设置正确的权限有点复杂,您必须尝试一下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM