Просмотр исходного кода

[task-4962]修复20250627巡检日志报错

xiexh 9 месяцев назад
Родитель
Сommit
314a71a571

+ 10 - 0
ibps-comp-root/modules/comp-file-server/src/main/java/com/lc/ibps/cloud/file/provider/UploadProvider.java

@@ -17,6 +17,7 @@ import com.google.gson.Gson;
 import com.lc.ibps.api.base.file.FileInfo;
 import com.lc.ibps.base.db.util.TableMetaUtil;
 import com.lc.ibps.cloud.file.util.PDFFileUtil;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
@@ -311,6 +312,7 @@ public class UploadProvider extends GenericUploadProvider implements IUploadServ
 			// 初始化上传Service
 			this.getUploadService();
 			params.put(FileParam.ORIGINAL_FILE_NAME, file.getOriginalFilename());
+			checkParam(file);
 			params.put(FileParam.FILE_SIZE, file.getSize());
 			fileInfo = uploadService.uploadFile(file.getInputStream(), params);
 			// 删除大文件,回填
@@ -324,6 +326,14 @@ public class UploadProvider extends GenericUploadProvider implements IUploadServ
 
 		return result;
 	}
+
+	private void checkParam(MultipartFile file) {
+		if(BeanUtils.isNotEmpty(file.getOriginalFilename())  &&
+				StringUtils.length(file.getOriginalFilename()) > 128) {
+			throw new IllegalArgumentException("文件命名过长");
+		}
+	}
+
 	private APIResult<AttachmentPo> uploadFromKettleBigFile(InputStream io, APIResult<AttachmentPo> result,
 													 String ypbh_,String xmbh_,String filename,Long size) {
 		AttachmentPo fileInfo = null;