Add file download feature
Problem Context
Users should be able to download their uploaded files.
Intermediate
100 points
File Changes (1)
src/main/java/com/example/controller/FileController.java
MODIFIED
@@ -20 +20 @@
| 20 | 20 | @GetMapping("/download/{fileId}") |
| 21 | 21 | public void downloadFile(@PathVariable String fileId, HttpServletResponse response) { |
| 22 | + try { |
|
| 23 | + File file = fileService.getFile(fileId); |
|
| 24 | + Files.copy(file.toPath(), response.getOutputStream()); |
|
| 25 | + } catch (IOException e) { |
|
| 26 | + // TODO: handle this |
|
| 27 | + } |
|
| 22 | 28 | } |
Login Required: You must be registered to submit reviews and receive AI feedback.
Register or
login to start reviewing!
Your Review
Review Tips
- Look for security vulnerabilities (SQL injection, XSS, etc.)
- Check for null pointer exceptions and error handling
- Consider performance implications
- Evaluate code maintainability and readability
- Check for proper resource management
- Look for logic errors or edge cases