|
@@ -118,7 +118,28 @@ public class AppendixController implements InitializingBean {
|
|
|
List<CommonAppendix> appendices = this.appendixService.getAppendixs(appendixIdList);
|
|
|
appendixWrapper.packAndDownloadByIdList(appendices, zipName);
|
|
|
}
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 后台通过服务器间接传文件
|
|
|
+ * @param file
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ @PostMapping("/api/upload")
|
|
|
+ @ResponseBody
|
|
|
+ public Object upload(@RequestParam("file") MultipartFile file) throws IOException {
|
|
|
+ ObjectMetadata objectMetadata = new ObjectMetadata();
|
|
|
+ objectMetadata.setContentLength(file.getSize());
|
|
|
+ objectMetadata.setContentType(file.getContentType());
|
|
|
+ String ext = FilenameUtils.getExtension(file.getOriginalFilename());
|
|
|
+ String uuid = GeneratorUtil.genFileName();
|
|
|
+ PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, "admin/" + uuid+"."+ext, file.getInputStream(), objectMetadata);
|
|
|
+ ossClient.putObject(putObjectRequest);
|
|
|
+ Map<String, Object> data = new HashMap<>();
|
|
|
+ data.put("url", baseUrl + "admin/" + uuid +"."+ext);
|
|
|
+ data.put("errno", 200);
|
|
|
+ data.put("errmsg", "成功");
|
|
|
+ return data;
|
|
|
+ }
|
|
|
/**
|
|
|
* 保存附件
|
|
|
*
|