Skip to content

Commit

Permalink
feat:add RandomString in posting file
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmy0006 committed Apr 8, 2024
1 parent e226333 commit 1980535
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public ResponseEntity sendFile(@PathVariable(name = "fileName") String fileName)
@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<String> uploadFile(@ModelAttribute MultipartFile file) {
try {
String fileNameWithOutSpace = file.getOriginalFilename().replace(' ', '-')+RandomStringGenerator();
String fileNameWithOutSpace = RandomStringGenerator()+file.getOriginalFilename().replace(' ', '-');
Path path = Paths.get(fileDir + fileNameWithOutSpace);
if (Files.exists(path)) {
return ResponseEntity.badRequest().body("이미 존재하는 파일명입니다. 파일 명을 수정해주세요");
Expand Down

0 comments on commit 1980535

Please sign in to comment.