🐛 fixed empty file
This commit is contained in:
parent
ffac5e7a3b
commit
1b2bf0fc03
@ -23,10 +23,12 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.*;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -186,9 +188,6 @@ public class UploadController {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String fileType = FileUtils.getExtend(orgName);
|
String fileType = FileUtils.getExtend(orgName);
|
||||||
String fileName = System.currentTimeMillis() + fileType;
|
|
||||||
String savePath = file.getPath() + File.separator + fileName;
|
|
||||||
File saveFile = new File(savePath);
|
|
||||||
try (InputStream in = multipartFile.getInputStream()) {
|
try (InputStream in = multipartFile.getInputStream()) {
|
||||||
String md5 = DigestUtils.md5DigestAsHex(in);
|
String md5 = DigestUtils.md5DigestAsHex(in);
|
||||||
String fileUrl = forestFileService.getFileUrlByMd5(md5, tokenUser.getIdUser(), fileType);
|
String fileUrl = forestFileService.getFileUrlByMd5(md5, tokenUser.getIdUser(), fileType);
|
||||||
@ -196,6 +195,9 @@ public class UploadController {
|
|||||||
successMap.put(orgName, fileUrl);
|
successMap.put(orgName, fileUrl);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
String fileName = System.currentTimeMillis() + fileType;
|
||||||
|
String savePath = file.getPath() + File.separator + fileName;
|
||||||
|
File saveFile = new File(savePath);
|
||||||
fileUrl = localPath + fileName;
|
fileUrl = localPath + fileName;
|
||||||
FileCopyUtils.copy(multipartFile.getBytes(), saveFile);
|
FileCopyUtils.copy(multipartFile.getBytes(), saveFile);
|
||||||
forestFileService.insertForestFile(fileUrl, savePath, md5, tokenUser.getIdUser(), multipartFile.getSize(), fileType);
|
forestFileService.insertForestFile(fileUrl, savePath, md5, tokenUser.getIdUser(), multipartFile.getSize(), fileType);
|
||||||
|
Loading…
Reference in New Issue
Block a user