-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathAWSConroller.java
More file actions
56 lines (47 loc) · 1.8 KB
/
AWSConroller.java
File metadata and controls
56 lines (47 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package kr.easw.lesson02.controller;
import kr.easw.lesson02.model.dto.AWSKeyDto;
import kr.easw.lesson02.service.AWSService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/rest/aws")
public class AWSConroller {
private final AWSService awsController;
@PostMapping("/auth")
private ModelAndView onAuth(AWSKeyDto awsKey) {
try {
awsController.initAWSAPI(awsKey);
return new ModelAndView("redirect:/");
} catch (Exception ex) {
ex.printStackTrace();
return new ModelAndView("redirect:/server-error?errorStatus=" + ex.getMessage());
}
}
@GetMapping("/list")
private List<String> onFileList() {
return awsController.getFileList();
}
@PostMapping("/upload")
private ModelAndView onUpload(@RequestParam MultipartFile file) {
try {
awsController.upload(file);
return new ModelAndView("redirect:/?success=true");
} catch (Exception ex) {
ex.printStackTrace();
return new ModelAndView("redirect:/server-error?errorStatus=" + ex.getMessage());
}
}
@PostMapping("/download")
private ModelAndView onDownload(@RequestParam String fileName) {
try {
// 이곳에 파일 다운로드 로직, 혹은 서비스를 통한 다운로드 호출을 구현하십시오.
throw new IllegalStateException("기능이 구현되지 않았습니다.");
} catch (Throwable e) {
return new ModelAndView("redirect:/server-error?errorStatus=" + e.getMessage());
}
}
}