Browse Source

增加测试上传方法

master
wxz 5 years ago
parent
commit
1c8e3b7204
  1. 31
      epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/TestController.java

31
epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/TestController.java

@ -0,0 +1,31 @@
package com.epmet.controller;
import com.epmet.commons.tools.utils.Result;
import org.apache.commons.io.FileUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@RestController
@RequestMapping("test")
public class TestController {
@PostMapping("local-upload")
public Result localUpload(@RequestPart("file") MultipartFile file) {
final File tempFile = new File("/opt/upload_files/temp");
try(InputStream inputStream = file.getInputStream()) {
FileUtils.copyInputStreamToFile(inputStream, tempFile);
} catch (IOException e) {
e.printStackTrace();
}
return new Result();
}
}
Loading…
Cancel
Save