Skip to content

Commit 4b215da

Browse files
authored
Feat: [Photo] 이미지 조회 오류 수정 (#66)
1 parent 32ecb79 commit 4b215da

3 files changed

Lines changed: 2 additions & 15 deletions

File tree

runtracker/src/main/java/com/runtracker/domain/upload/controller/UploadController.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,10 @@ public ApiResponse<Map<String, String>> uploadImage(
3636
public ResponseEntity<Resource> getImage(@PathVariable String filename) {
3737

3838
Resource resource = fileStorageService.loadFileAsResource(filename);
39-
String contentType = fileStorageService.determineContentType(resource);
4039

4140
return ResponseEntity.ok()
42-
.contentType(MediaType.parseMediaType(contentType))
43-
.header(HttpHeaders.CONTENT_DISPOSITION, "inline; filename=\"" + resource.getFilename() + "\"")
41+
.contentType(MediaType.parseMediaType("image/webp"))
42+
.header(HttpHeaders.CONTENT_DISPOSITION, "inline")
4443
.body(resource);
4544
}
4645
}

runtracker/src/main/java/com/runtracker/domain/upload/service/FileStorageService.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,4 @@ public Resource loadFileAsResource(String filename) {
8181
throw new FileNotFoundException(filename);
8282
}
8383
}
84-
85-
// 파일의 Content-Type을 결정
86-
public String determineContentType(Resource resource) {
87-
try {
88-
String contentType = Files.probeContentType(resource.getFile().toPath());
89-
return contentType != null ? contentType : "application/octet-stream";
90-
} catch (IOException ex) {
91-
log.info("Could not determine file type, using default");
92-
return "application/octet-stream";
93-
}
94-
}
9584
}

runtracker/src/test/java/com/runtracker/domain/upload/controller/UploadControllerTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public String getFilename() {
7878
}
7979
};
8080
when(fileStorageService.loadFileAsResource(anyString())).thenReturn(mockResource);
81-
when(fileStorageService.determineContentType(any())).thenReturn("image/webp");
8281

8382
// when & then
8483
this.mockMvc.perform(get("/api/upload/image/{filename}", filename))

0 commit comments

Comments
 (0)