Skip to content

Commit b0025a2

Browse files
committed
Java:MultiDataSource 解决上传文件报错 fileNames NPE
1 parent 5d02112 commit b0025a2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/java/apijson/boot/FileController.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ public JSONObject upload(@RequestParam("file") MultipartFile file) {
108108
fileOutputStream.write(file.getBytes());
109109
fileOutputStream.close();
110110

111-
fileNames.add(file.getOriginalFilename());
111+
if (fileNames != null && ! fileNames.isEmpty()) {
112+
fileNames.add(file.getOriginalFilename());
113+
}
112114

113115
JSONObject res = new JSONObject();
114116
res.put("path", "/download/" + file.getOriginalFilename());

0 commit comments

Comments
 (0)