Skip to content

Instantly share code, notes, and snippets.

@ezhov-da
Last active June 7, 2021 12:48
Show Gist options
  • Save ezhov-da/a9687559cc2b5eb9297fbf0d16777345 to your computer and use it in GitHub Desktop.
Save ezhov-da/a9687559cc2b5eb9297fbf0d16777345 to your computer and use it in GitHub Desktop.
java spark download random file
get("/file", ((request, response) -> {
response.header("Content-disposition", "attachment; filename=file.txt;");
File file = new File("E:\\_file-test.txt");
OutputStream outputStream = response.raw().getOutputStream();
outputStream.write(Files.readAllBytes(file.toPath()));
outputStream.flush();
return response;
}));
@ezhov-da
Copy link
Author

Easy. Use:

curl http://localhost:4567/file --output file1111.jpg

My full example on github.

curl examples: http://www.compciv.org/recipes/cli/downloading-with-curl/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment