mirror of
https://github.com/headporter81/specialsource-homepage-backend.git
synced 2026-12-06 07:41:09 +09:00
fix : 업로드 조각 저장 실패 시 원인을 응답에 담아 화면에 표시
SpecialSource Backend CI/CD / build-and-deploy (push) Successful in 55s
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:
1 parent
90cbedb1bb
commit
1fd7d581bd
1 file changed
+15
-9
@@ -158,16 +158,22 @@ public class MediaPostController {
|
||||
return ResponseEntity.badRequest().body(Map.of("error", "잘못된 업로드 요청입니다"));
|
||||
}
|
||||
Path temp = uploadDir(uploadId);
|
||||
Files.createDirectories(temp);
|
||||
Path part = temp.resolve(String.valueOf(fileIndex));
|
||||
try (java.nio.channels.FileChannel ch = java.nio.channels.FileChannel.open(part,
|
||||
java.nio.file.StandardOpenOption.CREATE, java.nio.file.StandardOpenOption.WRITE);
|
||||
java.io.InputStream in = chunk.getInputStream()) {
|
||||
ch.position(offset);
|
||||
in.transferTo(java.nio.channels.Channels.newOutputStream(ch));
|
||||
try {
|
||||
Files.createDirectories(temp);
|
||||
Path part = temp.resolve(String.valueOf(fileIndex));
|
||||
try (java.nio.channels.FileChannel ch = java.nio.channels.FileChannel.open(part,
|
||||
java.nio.file.StandardOpenOption.CREATE, java.nio.file.StandardOpenOption.WRITE);
|
||||
java.io.InputStream in = chunk.getInputStream()) {
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user