1

I created a Java app to store and download big files, so when the client upload a file it will be transfered to the server which will send it to storage cloud service ( azure data lake store ), however when a user try to download a file a request is sent to the server, then the server will send a request to the storage service and the transfert of the file will begin between the server and the storage service, meanwhile the client will be waiting for the transfersbetween these two to end, and this can take a long time ( step 3 in the bellow image ), I'm wondering if there a way to download what is been already collected from azure at the same time?

enter image description here

Here's my code:

@RequestMapping(value = "download", method = RequestMethod.GET, produces = "application/zip")
public ResponseEntity < Resource > download(@PathVariable String path) throws IOException {

    InputStream stream = azureDataLakeStoreService.getFile(path);
    InputStreamResource resource = new InputStreamResource(stream);

    return ResponseEntity.ok()
        .header(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, HttpHeaders.CONTENT_DISPOSITION)
        .header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=download.zip")
        .contentType(MediaType.parseMediaType("application/octet-stream"))
        .body(resource);
}
Svg_af
  • 225
  • 2
  • 9
  • Does this help: https://stackoverflow.com/questions/29637151/jersey-streamingoutput-as-response-entity ? ( I would assume you need such a streaming output, and then you simply stream the bytes coming in from your storage server immediately to the client ) – GhostCat Nov 16 '18 at 15:28
  • The slution that you are using shuld work. I just verifyed that serving a file from local disk. Can you share what is happening within getFile metohd. I think some problem might be there. – piotr szybicki Nov 16 '18 at 16:22

0 Answers0