|
|
@@ -2,10 +2,7 @@ package com.uas.report.controller;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
|
|
|
-import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.log4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
@@ -53,11 +50,11 @@ public class UploadController {
|
|
|
StringBuilder stringBuilder = new StringBuilder(jsRestAPIConf.getLocalBaseDir()).append("/").append(userName)
|
|
|
.append("/");
|
|
|
// 上传图片
|
|
|
- if (isPicture(fileName)) {
|
|
|
+ if (file.getContentType().contains("image")) {
|
|
|
stringBuilder.append("Picture").append("/");
|
|
|
}
|
|
|
// 上传报表模板
|
|
|
- if (isReportTemplate(fileName)) {
|
|
|
+ else if (isReportTemplate(fileName)) {
|
|
|
stringBuilder.append("jrxml").append("/");
|
|
|
}
|
|
|
stringBuilder.append(fileName);
|
|
|
@@ -80,23 +77,6 @@ public class UploadController {
|
|
|
return message;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 判断是否为图片
|
|
|
- *
|
|
|
- * @param fileName
|
|
|
- * @return
|
|
|
- */
|
|
|
- private boolean isPicture(String fileName) {
|
|
|
- if (StringUtils.isEmpty(fileName)) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- List<String> pictureTypes = new ArrayList<>();
|
|
|
- CollectionUtils.addAll(pictureTypes,
|
|
|
- new String[] { "bmp", "png", "jpg", "jpeg", "gif", "tiff", "psd", "swf", "svg" });
|
|
|
- String fileType = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
|
|
|
- return pictureTypes.contains(fileType);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 判断是否为jrxml报表模板文件
|
|
|
*
|