|
|
@ -14,8 +14,7 @@ import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import javax.imageio.ImageIO; |
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
import java.io.File; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.*; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
@ -116,14 +115,26 @@ public class FileBatchUploadComponent { |
|
|
|
if (!destFile.getParentFile().exists()) { |
|
|
|
destFile.getParentFile().mkdirs(); |
|
|
|
} |
|
|
|
try { |
|
|
|
/* try { |
|
|
|
file.transferTo(destFile); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
// 返回文件路劲
|
|
|
|
String fullUrl = urlPrefix + filePath; |
|
|
|
list.add(fullUrl); |
|
|
|
list.add(fullUrl);*/ |
|
|
|
try (InputStream inputStream = file.getInputStream(); |
|
|
|
BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(destFile))) { |
|
|
|
byte[] buffer = new byte[4096]; // 使用更大的缓冲区,4KB
|
|
|
|
int bytesRead; |
|
|
|
while ((bytesRead = inputStream.read(buffer)) != -1) { |
|
|
|
outputStream.write(buffer, 0, bytesRead); |
|
|
|
} |
|
|
|
list.add(urlPrefix + filePath); // 上传完成后加入返回结果列表
|
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
return rm.setMsg("文件上传失败"); |
|
|
|
} |
|
|
|
} else { |
|
|
|
return rm.setMsg("上传文件格式不正确"); |
|
|
|
} |
|
|
|