-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: 사용하지 않는 메서드 Deprecated 처리 * refactor: Resource 사용 부분 개선 (경로에 file:가 포함되는 문제) * refactor: file name 설정 위치 변경 * refactor: 파일 저장 관련 로직 Util 클래스로 분리 * refactor: File 저장 로직 분리! * refactor: 필드 이름 변경 * style: 클래스 이름 변경 * fix: 컴파일 에러 해결
- Loading branch information
Showing
11 changed files
with
93 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
server/src/main/java/sunflower/server/client/OcrDownloadClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
package sunflower.server.client; | ||
|
||
import java.io.File; | ||
|
||
public interface OcrDownloadClient { | ||
|
||
File download(final String pdfId); | ||
byte[] download(final String pdfId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package sunflower.server.util; | ||
|
||
import org.springframework.core.io.FileSystemResource; | ||
import org.springframework.core.io.Resource; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
public final class FileUtil { | ||
|
||
public static String savePdfFile(final MultipartFile file, String fileName) { | ||
final Path path = Paths.get("src", "main", "pdf", fileName); | ||
|
||
try { | ||
Files.copy(file.getInputStream(), path); | ||
Resource resource = new FileSystemResource(path.toFile()); | ||
return resource.getURI().getPath(); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
public static FileSystemResource convertToFileSystemResource(final MultipartFile file) { | ||
return (FileSystemResource) file.getResource(); | ||
} | ||
|
||
public static FileSystemResource convertToFileSystemResource(final File file) { | ||
return new FileSystemResource(file); | ||
} | ||
|
||
public static String saveLatexFile(final String pdfId, byte[] content) { | ||
final File file = new File("src/main/latex/" + pdfId + ".zip"); | ||
|
||
try (FileOutputStream fos = new FileOutputStream(file)) { | ||
fos.write(content); | ||
} catch (IOException e) { | ||
throw new RuntimeException("파일을 읽는데 실패함!"); | ||
} | ||
return file.getPath(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters