Skip to content

Commit

Permalink
remove unusing codes
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmy0006 committed Apr 11, 2024
1 parent 02ba4b6 commit 04fd0ae
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/main/java/org/poolc/api/file/controller/FileController.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ 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 = RandomStringGenerator()+file.getOriginalFilename().replace(' ', '-');
// String fileNameWithOutSpace = RandomStringGenerator()+file.getOriginalFilename().replace(' ', '-');
String fileNameWithOutSpace =file.getOriginalFilename().replace(' ', '-');
Path path = Paths.get(fileDir + fileNameWithOutSpace);
if (Files.exists(path)) {
return ResponseEntity.badRequest().body("이미 존재하는 파일명입니다. 파일 명을 수정해주세요");
Expand All @@ -60,14 +61,14 @@ public ResponseEntity<String> uploadFile(@ModelAttribute MultipartFile file) {
}
}

private String RandomStringGenerator(){
String SALTCHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
StringBuilder salt = new StringBuilder();
Random rnd = new Random();
for(int i=0;i<7;i++){
int index = (int) (rnd.nextFloat() * SALTCHARS.length());
salt.append(SALTCHARS.charAt(index));
}
return salt.toString();
}
// private String RandomStringGenerator(){
// String SALTCHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
// StringBuilder salt = new StringBuilder();
// Random rnd = new Random();
// for(int i=0;i<7;i++){
// int index = (int) (rnd.nextFloat() * SALTCHARS.length());
// salt.append(SALTCHARS.charAt(index));
// }
// return salt.toString();
// }
}

0 comments on commit 04fd0ae

Please sign in to comment.