简体   繁体   中英

Amazon S3 AWS SDK [Java] - MultiPart Upload how to get a custom header in the http response?

how can I access a custom header from a server response when using TransferManager ?

we have a custom header added in the response from our server, from the client side we use multi part upload with default transfer manager

any suggestion how in how i could hook up it ?

so basically i want to pass over the response from the return response.getAwsResponse(); found in the class: AmazonS3Client on the method

private <X, Y extends AmazonWebServiceRequest> X invoke(Request<Y> request,
                HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler,
                String bucket, String key, boolean isAdditionalHeadRequestToFindRegion) { 

that response will have the HTTP response from the server containing the custom heather which I'm after, basically is a unique Id send back when the file was 100% completed so than i can manipulate it.

I need to pass over this custom header from the response to the very beginning where I use the transfer manager and the upload.waitForCompletion(), also i don't want to edit the amazon's,

so does anyone know if there is an interface or some other object which provides me access to it ?

After some debug into the framework I strongly believe that there is no way to have access to the http response when using the TransferManager

for what we are trying to do we need to send an unique id from the server to the client when the file upload is completed and assembled

** therefore if you don't mind in do not use the beauty of the TransferManager you could write "your own TransferMananger" than you will have full control, but again on the client side we don't really want to add custom code but have a standard and simple approach (but that is for my scenario), if you decide to do it manually it can be done I have already tried and works !

So as a alternative we though in send from the server via the eTag, which is not great but will do the job and will keep the client side simple and clean

Any suggestion in how to send this value back in a better way ?

Upload up = tm.upload(bucketName, file.getName(), file);

UploadResult result = (UploadResult) ((UploadImpl) up).getMonitor().getFuture().get();
String uniqueIdFromServer = result.getETag();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM