10

如何通过 webservices API 将某个 S3 文件标记为 Make Public。

4

1 回答 1

36

使用方法setCannedAcl(CannedAccessControlList.PublicRead)更改访问控制权限。在此处阅读 java 文档以获取详细信息

示例代码:

BasicAWSCredentials basicAWSCredentials = new BasicAWSCredentials(ACCESS_KEY,SECRET_KEY);   
AmazonS3 s3 = new AmazonS3Client(basicAWSCredentials);

PutObjectRequest putObj = new PutObjectRequest(bucketName, objectKey, fileToUpload);

// making the object Public
putObj.setCannedAcl(CannedAccessControlList.PublicRead);

s3.putObject(putObj);
于 2012-04-09T15:53:30.003 回答