S3检索标签 - SdkClientException

时间:2018-03-12 12:02:13

标签: java amazon-web-services amazon-s3

我正在尝试以下列方式从s3上托管的文件中检索标记

public Map<String, String> getTags(@NonNull URI file) {
    GetObjectTaggingRequest getTaggingRequest = new GetObjectTaggingRequest(file.getHost(), removeLeadingSeparator(file.getPath()));
    GetObjectTaggingResult getTagsResult = s3Client.getObjectTagging(getTaggingRequest);
    List<Tag> tagList = getTagsResult.getTagSet();
    Map<String, String> out = new HashMap<>();
    tagList.forEach(t -> out.put(t.getKey(), t.getValue()));
    return out;
}

但我得到以下例外:

com.amazonaws.SdkClientException: Failed to parse XML document with handler class com.amazonaws.services.s3.model.transform.XmlResponsesSaxParser$GetObjectTaggingHandler

我的URI格式s3:// bucket / s3_key

我在s3上做的其他请求正常工作

https://docs.aws.amazon.com/AmazonS3/latest/dev/tagging-manage-javasdk.html

完整堆栈跟踪: com.amazonaws.SdkClientException:无法使用处理程序类com.amazonaws.services.s3.model.transform.XmlResponsesSaxParser解析XML文档$ GetObjectTaggingHandler

at com.amazonaws.services.s3.model.transform.XmlResponsesSaxParser.parseXmlInputStream(XmlResponsesSaxParser.java:156)
at com.amazonaws.services.s3.model.transform.XmlResponsesSaxParser.parseObjectTaggingResponse(XmlResponsesSaxParser.java:489)
at com.amazonaws.services.s3.model.transform.Unmarshallers$GetObjectTaggingResponseUnmarshaller.unmarshall(Unmarshallers.java:296)
at com.amazonaws.services.s3.model.transform.Unmarshallers$GetObjectTaggingResponseUnmarshaller.unmarshall(Unmarshallers.java:292)
at com.amazonaws.services.s3.internal.S3XmlResponseHandler.handle(S3XmlResponseHandler.java:62)
at com.amazonaws.services.s3.internal.ResponseHeaderHandlerChain.handle(ResponseHeaderHandlerChain.java:44)
at com.amazonaws.services.s3.internal.ResponseHeaderHandlerChain.handle(ResponseHeaderHandlerChain.java:30)
at com.amazonaws.http.response.AwsResponseHandlerAdapter.handle(AwsResponseHandlerAdapter.java:70)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleResponse(AmazonHttpClient.java:1503)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1226)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1030)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:742)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:716)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:699)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:667)
at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:649)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:513)
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:4221)
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:4168)
at com.amazonaws.services.s3.AmazonS3Client.getObjectTagging(AmazonS3Client.java:1503)
at tv.testtransferagent.protocols.S3Protocol.getTags(S3Protocol.java:166)

0 个答案:

没有答案