Commit 93d641d5 by guojuxing

上传文件

parent 67bed719
......@@ -7,6 +7,7 @@ import com.gic.thirdparty.BucketNameEnum;
import com.gic.thirdparty.FileOperateUtils;
import com.gic.thirdparty.pic.QQCloudPicUtils;
import com.gic.thirdparty.pic.UploadResult;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -84,8 +85,11 @@ public class UploadImgController {
bucketName = BucketNameEnum.VIDEO_40000.getName();
}
String url = FileOperateUtils.simpleUploadFileFromLocal(targetFile, fieldCode, bucketName);
if (StringUtils.isNotBlank(url)) {
url = "https://" + url;
}
Map<String, Object> pic = new HashMap<>();
Map<String, Object> pic = new HashMap<>(8);
pic.put("fileId", fieldCode);
pic.put("url", url);
pic.put("fileName", fileRealName);
......@@ -154,24 +158,24 @@ public class UploadImgController {
public static boolean isPicture(String fileSuffix) throws Exception{
String[] imageArray =
{"bmp", "dib","gif", "jfif", "jpe","jpeg", "jpg", "png", "tif", "tiff", "ico", "10"};
return Arrays.stream(imageArray).anyMatch(e -> e.equals(fileSuffix));
return Arrays.stream(imageArray).anyMatch(e -> e.equals(fileSuffix.replace(".", "")));
}
public static boolean isOffice(String fileSuffix) throws Exception{
String[] arr =
{"doc", "docx","xls", "xlsx", "pptx", "ppt"};
return Arrays.stream(arr).anyMatch(e -> e.equals(fileSuffix));
return Arrays.stream(arr).anyMatch(e -> e.equals(fileSuffix.replace(".", "")));
}
public static boolean isMusic(String fileSuffix) throws Exception{
String[] arr =
{"wma", "mpc","ogg", "wav", "mpeg", "mp3"};
return Arrays.stream(arr).anyMatch(e -> e.equals(fileSuffix));
return Arrays.stream(arr).anyMatch(e -> e.equals(fileSuffix.replace(".", "")));
}
public static boolean isVedio(String fileSuffix) throws Exception{
String[] arr =
{"rm", "rmvb","mp4", "wmv", "asf", "asx", "3gp", "mov", "m4v", "avi", "dat", "mkv", "flv", "vob"};
return Arrays.stream(arr).anyMatch(e -> e.equals(fileSuffix));
return Arrays.stream(arr).anyMatch(e -> e.equals(fileSuffix.replace(".", "")));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment