|
@@ -1,8 +1,10 @@
|
|
|
package com.css.simulation.resource.common.controller;
|
|
|
|
|
|
import api.common.pojo.common.ResponseBodyVO;
|
|
|
+import api.common.pojo.constants.DictConstants;
|
|
|
import api.common.pojo.param.MinioParameter;
|
|
|
import api.common.util.FileUtil;
|
|
|
+import api.common.util.TimeUtil;
|
|
|
import com.css.simulation.resource.common.util.MinioUtil;
|
|
|
import io.minio.MinioClient;
|
|
|
import io.minio.errors.*;
|
|
@@ -15,11 +17,15 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.security.InvalidKeyException;
|
|
|
import java.security.NoSuchAlgorithmException;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("/minio")
|
|
@@ -60,21 +66,31 @@ public class MinioController {
|
|
|
@PostMapping(value = "/uploadProcessBar", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
|
|
public ResponseBodyVO<String> uploadProcessBar(
|
|
|
@RequestPart("file") MultipartFile file,
|
|
|
- @RequestParam("objectName") String objectName,// "/xx/xxx/x/xx"
|
|
|
- @RequestParam("objectPath") String objectPath
|
|
|
+ HttpServletRequest request
|
|
|
) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
|
|
|
-
|
|
|
- MinioUtil.uploadProcessBar(
|
|
|
- minioClient,
|
|
|
- file,
|
|
|
- bucketName,
|
|
|
- objectName,
|
|
|
- objectPath,
|
|
|
- redisController
|
|
|
- );
|
|
|
- String previewUrl = MinioUtil.getPreviewUrl(minioClient, Method.GET, bucketName, objectName);
|
|
|
-
|
|
|
- return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, "请求成功!", previewUrl);
|
|
|
+ String type = request.getParameter("type");
|
|
|
+ String objectPath = request.getParameter("objectPath");
|
|
|
+ if (file != null){
|
|
|
+ String objectName = "";
|
|
|
+ Integer nowTime = TimeUtil.getRq(new Date(), 0);
|
|
|
+ if (type.equals(DictConstants.ALGORITHM_FILE)) {
|
|
|
+ objectName = "algorithm/" + nowTime + "/" + objectPath + "/" + file.getOriginalFilename();
|
|
|
+ }
|
|
|
+
|
|
|
+ MinioUtil.uploadProcessBar(
|
|
|
+ minioClient,
|
|
|
+ file,
|
|
|
+ bucketName,
|
|
|
+ objectName,
|
|
|
+ objectPath,
|
|
|
+ redisController
|
|
|
+ );
|
|
|
+ Map map = new HashMap();
|
|
|
+ map.put("fileName", objectName);
|
|
|
+
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, map);
|
|
|
+ }
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "文件流file为空,请检查!");
|
|
|
}
|
|
|
|
|
|
// @PostMapping("/download")
|