英文:
ListObjectsV2 access denied Java SDK
问题
我正在尝试使用以下 Java 代码列出指定前缀下存储桶中的所有对象:
ListObjectsV2Request request =
new ListObjectsV2Request()
.withBucketName(bucketName)
.withDelimiter("/")
.withPrefix(prefix)
.withMaxKeys(2);
ListObjectsV2Result result;
do {
result = s3Client.listObjectsV2(req);
log.info("结果大小为:" + result.getObjectSummaries().size());
s3Client
已正确设置,因为我可以进行上传、删除等操作。我只在列出对象时遇到问题。如果不提供前缀,我会收到访问被拒绝的错误;但如果提供前缀,我会收到空响应。我使用了 aws s3 ls
进行了权限测试,能够打印出整个存储桶的内容。有关调试的下一步想法吗?
<details>
<summary>英文:</summary>
I'm trying to list all objects in a bucket under a prefix with the following code in java:
ListObjectsV2Request request =
new ListObjectsV2Request()
.withBucketName(bucketName)
.withDelimiter("/")
.withPrefix(prefix)
.withMaxKeys(2);
ListObjectsV2Result result;
do {
result = s3Client.listObjectsV2(req);
log.info("Results size is : " + result.getObjectSummaries().size());
The s3client is set up correctly because I can upload, delete, etc. I only have a problem listing objects. I receive access denied if I don't provide a prefix, but if I provide a prefix I receive an empty response. I tested `aws s3 ls` to see if I had permissions and I'm able to print the whole bucket out that way. Any ideas for next steps for debugging?
</details>
# 答案1
**得分**: 0
通过ssh登录到实例并比较aws s3 ls和s3api的输出进行了解决。忘记了必需的前缀和分隔符。
<details>
<summary>英文:</summary>
Solved by sshing into instance and comparing the output of aws s3 ls & s3api. Had forgotten mandatory prefix and delimiter.
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论