|
@@ -2,12 +2,19 @@ package com.css.simulation.resource.scheduler.feign;
|
|
|
|
|
|
import api.common.pojo.common.ResponseBodyVO;
|
|
|
import api.common.pojo.param.KafkaParameter;
|
|
|
+import api.common.pojo.param.MinioParameter;
|
|
|
+import api.common.util.FileUtil;
|
|
|
+import feign.Response;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+
|
|
|
@RestController
|
|
|
@RequestMapping("/demo")
|
|
|
public class DemoController {
|
|
@@ -19,7 +26,18 @@ public class DemoController {
|
|
|
public ResponseBodyVO<String> upload(@RequestPart("file") MultipartFile file,
|
|
|
@RequestParam("objectName") String objectName) {
|
|
|
|
|
|
- return demoService.upload(file,objectName);
|
|
|
+ return demoService.upload(file, objectName);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/download")
|
|
|
+ public void download(
|
|
|
+ @RequestBody @Validated MinioParameter minioParameter,
|
|
|
+ HttpServletResponse response
|
|
|
+ ) throws IOException {
|
|
|
+ Response download = demoService.download(minioParameter);
|
|
|
+ Response.Body body = download.body();
|
|
|
+ InputStream inputStream = body.asInputStream();
|
|
|
+ FileUtil.downloadForHttp(minioParameter.getObjectName(), inputStream, response, 1024);
|
|
|
}
|
|
|
|
|
|
@PostMapping(value = "/send", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|