|
@@ -10,7 +10,6 @@ package cn.com.qmth.examcloud.core.print.api.controller;
|
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
import cn.com.qmth.examcloud.core.print.common.Result;
|
|
|
import cn.com.qmth.examcloud.core.print.common.upyun.UpYunClient;
|
|
|
-import cn.com.qmth.examcloud.core.print.common.upyun.UpYunProperty;
|
|
|
import cn.com.qmth.examcloud.core.print.common.utils.Check;
|
|
|
import cn.com.qmth.examcloud.core.print.common.utils.FileUtils;
|
|
|
import io.swagger.annotations.Api;
|
|
@@ -39,18 +38,6 @@ public class CommonController extends ControllerSupport {
|
|
|
@Autowired
|
|
|
private UpYunClient upYunClient;
|
|
|
|
|
|
- @GetMapping("/download")
|
|
|
- @ApiOperation(value = "下载文件")
|
|
|
- public void download(@RequestParam String filePath) throws Exception {
|
|
|
- File file = upYunClient.download(filePath);
|
|
|
- final String fileName = FileUtils.getFileName(filePath);
|
|
|
- if (file != null) {
|
|
|
- super.exportFile(fileName, file);
|
|
|
- } else {
|
|
|
- super.exportFile("404", new byte[0]);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
@PostMapping("/upload")
|
|
|
@ApiOperation(value = "上传文件")
|
|
|
public Result upload(HttpServletRequest request) throws Exception {
|
|
@@ -66,9 +53,16 @@ public class CommonController extends ControllerSupport {
|
|
|
return upYunClient.upload(file.getBytes(), file.getOriginalFilename());
|
|
|
}
|
|
|
|
|
|
- @PostMapping("/upyun/info")
|
|
|
- public UpYunProperty getUpYunInfo() {
|
|
|
- return upYunClient.getProperty();
|
|
|
+ @GetMapping("/download")
|
|
|
+ @ApiOperation(value = "下载文件")
|
|
|
+ public void download(@RequestParam String filePath) throws Exception {
|
|
|
+ File file = upYunClient.download(filePath);
|
|
|
+ if (file != null) {
|
|
|
+ super.exportFile(FileUtils.getFileName(filePath), file);
|
|
|
+ } else {
|
|
|
+ //文件不存在
|
|
|
+ super.exportFile("404", new byte[0]);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|