Skip to content

Commit 5ef3f29

Browse files
authored
fix: Correct file download path error (#81)
2 parents 1b69125 + 2bb43b0 commit 5ef3f29

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.env
22
*.7z
33
frontend-nextjs
4-
frontend-prev
4+
frontend-prev
5+
.idea

backend/main-service/src/main/java/io/blog/devlog/domain/file/controller/DownloadController.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import io.blog.devlog.domain.file.model.File;
44
import io.blog.devlog.domain.file.service.FileService;
55
import lombok.RequiredArgsConstructor;
6+
import lombok.extern.slf4j.Slf4j;
67
import org.springframework.beans.factory.annotation.Value;
78
import org.springframework.core.io.Resource;
89
import org.springframework.core.io.UrlResource;
@@ -15,10 +16,10 @@
1516
import org.springframework.web.bind.annotation.RestController;
1617

1718
import java.io.IOException;
18-
import java.nio.file.Files;
1919
import java.nio.file.Path;
2020
import java.nio.file.Paths;
2121

22+
@Slf4j
2223
@RequiredArgsConstructor
2324
@RestController
2425
@RequestMapping("/download")
@@ -35,6 +36,7 @@ public ResponseEntity<Resource> getImage(@PathVariable int year,
3536
@PathVariable String fileName) throws IOException {
3637
String fileUrl = String.format("%04d/%02d/%02d/%s", year, month, day, fileName);
3738
String filePath = String.format("%s/%s", uploadPath, fileUrl);
39+
log.info("fileDownloadPath : {}", filePath);
3840
Path path = Paths.get(filePath);
3941
Resource resource = new UrlResource(path.toUri());
4042

frontend/src/components/post/Post.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function Post({ ...props }) {
8888
onClick={null}
8989
>
9090
<a
91-
href={`${process.env.NEXT_PUBLIC_API_ENDPOINT}/download/${file.fileUrl}`}
91+
href={`${process.env.NEXT_PUBLIC_API_ENDPOINT}/main/download/${file.fileUrl}`}
9292
download={file.fileName}
9393
>
9494
<p className="file-upload-file-name">

0 commit comments

Comments
 (0)