|
@@ -9,6 +9,7 @@ import org.springframework.http.converter.HttpMessageNotReadableException;
|
|
|
import org.springframework.http.converter.HttpMessageNotWritableException;
|
|
import org.springframework.http.converter.HttpMessageNotWritableException;
|
|
|
|
|
|
|
|
import java.io.*;
|
|
import java.io.*;
|
|
|
|
|
+import java.util.UUID;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 实现 PUT 请求上传文件
|
|
* 实现 PUT 请求上传文件
|
|
@@ -31,7 +32,9 @@ public class FileMessageConverter extends AbstractHttpMessageConverter<File> {
|
|
|
throws IOException, HttpMessageNotReadableException {
|
|
throws IOException, HttpMessageNotReadableException {
|
|
|
|
|
|
|
|
InputStream inputStream = inputMessage.getBody();
|
|
InputStream inputStream = inputMessage.getBody();
|
|
|
- File tmpFile = File.createTempFile("upload",".dat");
|
|
|
|
|
|
|
+ String tmpPath = String.format("/opt/tmp/tomcat/%s.dat", UUID.randomUUID());
|
|
|
|
|
+ File tmpFile = new File(tmpPath);
|
|
|
|
|
+ tmpFile.createNewFile();
|
|
|
if (inputStream != null) {
|
|
if (inputStream != null) {
|
|
|
FileOutputStream outputStream = new FileOutputStream(tmpFile);
|
|
FileOutputStream outputStream = new FileOutputStream(tmpFile);
|
|
|
|
|
|