fix : 업로드 조각 저장 실패 시 원인을 응답에 담아 화면에 표시
SpecialSource Backend CI/CD / build-and-deploy (push) Successful in 55s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
headporterandClaude Opus 5.5 committed 2026-11-30 11:32:47 +09:00
1 parent 90cbedb1bb
commit 1fd7d581bd
1 file changed
+15 -9
@@ -158,16 +158,22 @@ public class MediaPostController {
return ResponseEntity.badRequest().body(Map.of("error", "잘못된 업로드 요청입니다")); return ResponseEntity.badRequest().body(Map.of("error", "잘못된 업로드 요청입니다"));
} }
Path temp = uploadDir(uploadId); Path temp = uploadDir(uploadId);
Files.createDirectories(temp); try {
Path part = temp.resolve(String.valueOf(fileIndex)); Files.createDirectories(temp);
try (java.nio.channels.FileChannel ch = java.nio.channels.FileChannel.open(part, Path part = temp.resolve(String.valueOf(fileIndex));
java.nio.file.StandardOpenOption.CREATE, java.nio.file.StandardOpenOption.WRITE); try (java.nio.channels.FileChannel ch = java.nio.channels.FileChannel.open(part,
java.io.InputStream in = chunk.getInputStream()) { java.nio.file.StandardOpenOption.CREATE, java.nio.file.StandardOpenOption.WRITE);
ch.position(offset); java.io.InputStream in = chunk.getInputStream()) {
in.transferTo(java.nio.channels.Channels.newOutputStream(ch)); ch.position(offset);
in.transferTo(java.nio.channels.Channels.newOutputStream(ch));
}
// 다 쓴 뒤에 표시 → 표시가 있으면 그 조각은 확실히 들어감
Files.write(temp.resolve(fileIndex + "." + chunkIndex + ".ok"), new byte[0]);
} catch (Exception e) {
// 서버 로그를 바로 못 보는 환경이라 원인을 화면까지 전달 (로그인한 사용자만 호출 가능)
e.printStackTrace();
return ResponseEntity.status(500).body(Map.of("error", "조각 저장 실패: " + e));
} }
// 다 쓴 뒤에 표시 → 표시가 있으면 그 조각은 확실히 들어감
Files.write(temp.resolve(fileIndex + "." + chunkIndex + ".ok"), new byte[0]);
return ResponseEntity.noContent().build(); return ResponseEntity.noContent().build();
} }