如何在多个对象上设置S3存储桶策略?
Statement allowRestrictedWriteStatement = new Statement(Effect.Allow)
.withPrincipals(new Principal("12345678910"))
.withActions(S3Actions.DeleteObject)
.withResources(new S3ObjectResource(myBucketName, "folder1/folder2"));
Statement allowRestrictedWriteStatement2 = new Statement(Effect.Deny)
.withPrincipals(new Principal("12345678910"))
.withActions(S3Actions.DeleteObject)
.withResources(new S3ObjectResource(myBucketName, "folder1/folder3"));
Policy policy = new Policy()
.withStatements(allowRestrictedWriteStatement,allowRestrictedWriteStatement2);
AWSCredentials credentials = new BasicAWSCredentials("xxxxxxxxxxxxx", "yyyyyyyyyyy");
AmazonS3 s3client = new AmazonS3Client(credentials);
s3client.setBucketPolicy(myBucketName,policy.toJson());
借助以上代码,我可以在两个存储桶对象上设置允许和拒绝权限。如果我们需要对两个列表中可用的对象设置允许和拒绝该怎么办,即listAllow和listDeny分别包含5个对象,我需要在这些列表对象上设置存储桶策略。有任何建议吗?。
答案 0 :(得分:0)
我找到了解决方法-
Logger.log