将 s3 图像从一个存储桶复制到同一帐户的另一个存储桶后未加载
s3 images not loading after copying it from one bucket to another of same account
我已将图像从一个存储桶复制到另一个存储桶,但现在我无法访问图像。错误显示
AccessDenied
留言。
我已验证存储桶中存在文件但无法访问它。如果我删除相同的图像并再次上传它,那么它就可以工作了。
如果我在将存储桶数据从一个存储桶数据复制到另一个存储桶期间遗漏任何内容,请提出任何原因。
Link 使用旧存储桶,现在无法使用新存储桶访问
https://abc.s3.amazonaws.com/uploads/profile/image/16923/client_thumb_CINDERELLA_12
您正在尝试访问 S3 对象的 public URL,只有当您打开存储桶 publically 时它才有效。您必须将新存储桶设置为 publically accessible 并且 ALSO 设置存储桶策略,例如:
{
"Version":"2012-10-17",
"Statement":[
{
"Sid":"PublicRead",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::examplebucket/*"]
}
]
}
其中 examplebucket
是存储桶的名称。
S3 中的复制(或任何放置操作)默认是私有的,因为这是默认的 ACL 行为,请参阅 here。这就是为什么即使源文件启用了 public 访问权限,您也会被拒绝访问。因此,您需要在复制过程中将 ACL 指定为 public-read
,在您的情况下(cli 示例):
aws s3 cp s3://mySourceBucket/test.txt s3://myDestinationBucket/test.txt --acl public-read
请注意,根据 AWS,如果您使用 --acl
,您的 IAM 策略必须包含 S3:PutObjectAcl
操作。
--acl (string) Sets the ACL for the object when the command is performed. If you use this parameter you must have the "s3:PutObjectAcl" permission included in the list of actions for your IAM policy. Only accepts values of private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control and log-delivery-write. See Canned ACL for details
我已将图像从一个存储桶复制到另一个存储桶,但现在我无法访问图像。错误显示
AccessDenied
留言。
我已验证存储桶中存在文件但无法访问它。如果我删除相同的图像并再次上传它,那么它就可以工作了。
如果我在将存储桶数据从一个存储桶数据复制到另一个存储桶期间遗漏任何内容,请提出任何原因。
Link 使用旧存储桶,现在无法使用新存储桶访问
https://abc.s3.amazonaws.com/uploads/profile/image/16923/client_thumb_CINDERELLA_12
您正在尝试访问 S3 对象的 public URL,只有当您打开存储桶 publically 时它才有效。您必须将新存储桶设置为 publically accessible 并且 ALSO 设置存储桶策略,例如:
{
"Version":"2012-10-17",
"Statement":[
{
"Sid":"PublicRead",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::examplebucket/*"]
}
]
}
其中 examplebucket
是存储桶的名称。
S3 中的复制(或任何放置操作)默认是私有的,因为这是默认的 ACL 行为,请参阅 here。这就是为什么即使源文件启用了 public 访问权限,您也会被拒绝访问。因此,您需要在复制过程中将 ACL 指定为 public-read
,在您的情况下(cli 示例):
aws s3 cp s3://mySourceBucket/test.txt s3://myDestinationBucket/test.txt --acl public-read
请注意,根据 AWS,如果您使用 --acl
,您的 IAM 策略必须包含 S3:PutObjectAcl
操作。
--acl (string) Sets the ACL for the object when the command is performed. If you use this parameter you must have the "s3:PutObjectAcl" permission included in the list of actions for your IAM policy. Only accepts values of private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control and log-delivery-write. See Canned ACL for details