Commit e3d7b2bc authored by unknown's avatar unknown
Browse files

Specifying "href" attribute to be the file path to the text file in the

current working directory.
parent ebf76c2c
Pipeline #170926 passed with stages
in 46 seconds
......@@ -33,7 +33,7 @@ public class HTMLResultPage implements Page {
writer.println("<h1>" + query + "</h1>");
writer.println("<p>" + answer.replace("\n", "<br>") + "</p>");
// Create file
String downloadableFileName = System.nanoTime() + ".txt";
String downloadableFileName = query + ".txt";
File downloadableFile = new File(downloadableFileName);
if (downloadableFile.createNewFile()) {
// File didn't exist previous
......@@ -42,7 +42,8 @@ public class HTMLResultPage implements Page {
downloadableFileWriter.write(answer);
// Reference file in html
writer.println("<p>" +
String.format("<a id=\"download_link\" href=\"\" download=\"%s\">", downloadableFileName) +
String.format("<a id=\"download_link\" href=\"/%s\" download=\"%s\">", downloadableFileName,
downloadableFileName) +
"Download file</a>" +
"</p>");
downloadableFileWriter.close();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment