Home:ALL Converter>Download a file from a url

Download a file from a url

Ask Time:2018-03-09T23:18:33         Author:user9463015

Json Formatter

My way of downloading a file from a docker is by using:

Backend

url = "http://" + settings.getDockerIP() + ":" + settings.getDockerPort() + "/containers/" + container.getId() + "/archive?path=/path";

Frontend

<div class="fm-file-icon">
    <a href="${file}"><img src="../resources/img/folder.png"></a>
  </div>

Controller

 @RequestMapping("/report")
public ModelAndView report(HttpServletRequest request) { 
    String environmentName = request.getParameter("name"); 
    ModelAndView model = new ModelAndView("report");
    model.addObject("file", Report.getFileFromContainer(environmentName));

    return model;
}

The problem is that to download the file you also need a connection to settings.getDockerIP():settings.getDockerPort() and I don't want that. I just want to be able for the user to download the file by accessing the site without having the connection to the docker itself.

How can I do this? Maybe I need to download the file on the backend and then pass the url to the file in my server?

Author:user9463015,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/49196851/download-a-file-from-a-url
yy