Skip to content

Commit

Permalink
fix download param in html, controller, clean files
Browse files Browse the repository at this point in the history
  • Loading branch information
yennanliu committed Nov 14, 2023
1 parent 02d8623 commit 69fb996
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,13 @@ public String createDownload() {

// TODO : fix : make GET request with report id
@GetMapping("/download_report")
public ResponseEntity<Resource> downloadFile() throws IOException {
public ResponseEntity<Resource> downloadFile(String url) throws IOException {

// Load the file from the classpath (assuming it's in the resources/static directory)
// Resource resource = new ClassPathResource("/test.json");
// HttpHeaders headers = new HttpHeaders();
// headers.add(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=test.json");

List<DownloadStatus> downloadStatusList = downloadStatusMapper.getAllDownloadStatus();
// TODO : fix below (currently only get 1st downloadStatus)
String downloadUrl = "/report/" + downloadStatusList.get(0).getDownloadUrl();
log.info(">>> (ResponseEntity<Resource> downloadFile) url = " + url);
//List<DownloadStatus> downloadStatusList = downloadStatusMapper.getAllDownloadStatus();
//String downloadUrl = "/report/" + downloadStatusList.get(0).getDownloadUrl();
String downloadUrl = "/report/" + url;
log.info("downloadUrl = " + downloadUrl);
Resource resource = new ClassPathResource(downloadUrl);
HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=%s".format("test.json"));
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,11 @@ <h3 class="title">Report Download</h3>
<td th:text="${download.id}" nowrap></td>
<td id="name" th:text="${download.downloadUrl}" nowrap></td>
<td id="city" th:text="${download.status}" nowrap></td>
<!--
HTML button send GET or POST request
https://stackoverflow.com/questions/46987384/html-form-post-or-get-depending-on-button-clicked
-->
<td>
<a href="/download/download_report">
<a href="/download/download_report">Download File</a>
<a th:href="@{'/download/download_report?url=' + ${download.downloadUrl}}">
Download File
</a>
</td>

</tr>

</table>
Expand Down

0 comments on commit 69fb996

Please sign in to comment.