获取AmazonS3Exception:将存储桶名称作为bucket-name / 10020 /传递时,指定的密钥不存在

时间:2017-12-21 10:32:07

标签: amazon-web-services amazon-s3

我使用下面的代码来获取存储桶中的对象。 我期待一个空的响应,但代码在这里抛出异常。

final ListObjectsRequest listObjectRequest = new ListObjectsRequest().withBucketName(s3Bucket)
                .withMaxKeys(1).withPrefix(prefix);
        final ObjectListing objectListing = s3client.listObjects(listObjectRequest);

参数: s3_bucket => “my-bucket / incoming /”和prefix => “PRE _”

例外:

com.amazonaws.services.s3.model.AmazonS3Exception: The specified key does not exist. (Service: Amazon S3; Status Code: 404; Error Code: NoSuchKey; Request ID: BF85E6E0CF00717E)
at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1181) ~[aws-java-sdk-core-1.10.24.jar:?]
at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:766) ~[aws-java-sdk-core-1.10.24.jar:?]
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:485) ~[aws-java-sdk-core-1.10.24.jar:?]
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:306) ~[aws-java-sdk-core-1.10.24.jar:?]
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3604) ~[aws-java-sdk-s3-1.10.24.jar:?]
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3557) ~[aws-java-sdk-s3-1.10.24.jar:?]
at com.amazonaws.services.s3.AmazonS3Client.listObjects(AmazonS3Client.java:647) ~[aws-java-sdk-s3-1.10.24.jar:?]

0 个答案:

没有答案