How to write a java program to download a file from a unix server in a cluster to a calling client

34 Views Asked by At

I work in an environment where customer sends a HTTP Request to download a file which can sit on multiple servers in a cluster. There are around 5-10 servers in a cluster and the request to download the file can come to any server in the cluster. Technically I can know the IP of the Linux Server on the file is present. Now The approach that I am considering is to initiate a SFTP Connection to the known IP Address using JSch Library and fetch the file to the server where the HTTP Request first came. But the file is of 1-2 GB and I have to SFTP entire file to my primary server where the request came and from there send back the file in HTTP Response as application/octet-stream. Is there any alternative way where I do not have to copy entire file and then send back HTTP Response. Is there a way to use Lambda function to call the Target Server and to initiate download of that file from there directly to the client. Any answers and help might be really appreciated. This file download process is entirely in java. Can I use Java Lambdas to trigger file download from the target server directly to the caller.

0

There are 0 best solutions below