我们正在尝试使用TransferManager从Amazon S3下载文件。但是TransferManager在doDownload函数中多次使用getObjectMetadata服务。并通过从我提供的初始请求中复制普通成员来调用那些创建请求的服务。
问题是我添加了一些自定义标头,包括授权标头。而且getObjectMetadata需要该标头。所以我必须修改一些sdk类。</ p>
AmazonS3Client.java
let arr = ['5', '-5', '.5', '5.', '0', '5e0', '5E0', 'Infinity', '-Infinity', '5a', 'n', '--5'];
arr.forEach(str => console.log(str, !isNaN(str) && isFinite(str) && !/e/i.test(str)))
RequestCopyUtils.java
protected <X extends AmazonWebServiceRequest> Request<X> createRequest(String bucketName, String key, X originalRequest, HttpMethodName httpMethod, URI endpoint) {
// If the underlying AmazonS3Client has enabled accelerate mode and the original
// request operation is accelerate mode supported, then the request will use the
// s3-accelerate endpoint to performe the operations.
if (clientOptions.isAccelerateModeEnabled() && !(originalRequest instanceof S3AccelerateUnsupported)) {
if (clientOptions.isDualstackEnabled()) {
endpoint = RuntimeHttpUtils.toUri(Constants.S3_ACCELERATE_DUALSTACK_HOSTNAME, clientConfiguration);
} else {
endpoint = RuntimeHttpUtils.toUri(Constants.S3_ACCELERATE_HOSTNAME, clientConfiguration);
}
}
Request<X> request = new DefaultRequest<X>(originalRequest, Constants.S3_SERVICE_DISPLAY_NAME);
request.setHttpMethod(httpMethod);
request.addHandlerContext(S3HandlerContextKeys.IS_CHUNKED_ENCODING_DISABLED,
Boolean.valueOf(clientOptions.isChunkedEncodingDisabled()));
request.addHandlerContext(S3HandlerContextKeys.IS_PAYLOAD_SIGNING_ENABLED,
Boolean.valueOf(clientOptions.isPayloadSigningEnabled()));
//my code starts here
if ( originalRequest.getCustomRequestHeaders() != null ) {
Set<String> keys = originalRequest.getCustomRequestHeaders().keySet();
for (Iterator<String> iterator = keys.iterator(); iterator.hasNext();) {
String headerKey = iterator.next();
request.addHeader(headerKey, originalRequest.getCustomRequestHeaders().get(headerKey));
}
}
//my code ends here
resolveRequestEndpoint(request, bucketName, key, endpoint);
request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
return request;
}
对我来说,这似乎是一个错误。但是有什么适当的解决方案吗?
致谢