Commit 8eb3d21a by yao.xiao

测试-富文本文件上传

parent dee9925a
......@@ -46,7 +46,7 @@ public class AgmsSharingServiceImpl implements AgmsSharingService {
".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".md", ".xml"};
if ("config".equals(action)) {
String aliOssBucketName = systemConfigService.getSingleConfigValue("ALI_OSS_BUCKET_NAME");
String generateUrl = aliOssInterfService.generateUrl(aliOssBucketName, null);
String generateUrl = aliOssInterfService.generateUrl(aliOssBucketName, "sharing");
responseVO.setImageActionName("uploadimage");
responseVO.setImageFieldName("upfile");
responseVO.setImageMaxSize(2048000);
......@@ -55,46 +55,46 @@ public class AgmsSharingServiceImpl implements AgmsSharingService {
responseVO.setImageCompressBorder(1600);
responseVO.setImageInsertAlign("none");
responseVO.setImageUrlPrefix(generateUrl);
responseVO.setImagePathFormat("/sharing/image/{time}{rand:6}");
responseVO.setImagePathFormat("/image/{time}{rand:6}");
responseVO.setScrawlActionName("uploadscrawl");
responseVO.setScrawlFieldName("upfile");
responseVO.setScrawlPathFormat("/sharing/image/{time}{rand:6}");
responseVO.setScrawlPathFormat("/image/{time}{rand:6}");
responseVO.setScrawlMaxSize(2048000);
responseVO.setScrawlUrlPrefix(generateUrl);
responseVO.setScrawlInsertAlign("none");
responseVO.setSnapscreenActionName("uploadimage");
responseVO.setSnapscreenPathFormat("/sharing/image/{time}{rand:6}");
responseVO.setSnapscreenPathFormat("/image/{time}{rand:6}");
responseVO.setSnapscreenUrlPrefix(generateUrl);
responseVO.setSnapscreenInsertAlign("none");
String[] catcherLocalDomain = new String[]{"127.0.0.1", "localhost", "img.baidu.com"};
responseVO.setCatcherLocalDomain(Arrays.asList(catcherLocalDomain));
responseVO.setCatcherActionName("catchimage");
responseVO.setCatcherFieldName("source");
responseVO.setCatcherPathFormat("/sharing/image/{time}{rand:6}");
responseVO.setCatcherPathFormat("/image/{time}{rand:6}");
responseVO.setCatcherUrlPrefix(generateUrl);
responseVO.setCatcherMaxSize(2048000);
responseVO.setCatcherAllowFiles(Arrays.asList(imageAllowFiles));
responseVO.setVideoActionName("uploadvideo");
responseVO.setVideoFieldName("upfile");
responseVO.setVideoPathFormat("/sharing/video/{time}{rand:6}");
responseVO.setVideoPathFormat("/video/{time}{rand:6}");
responseVO.setVideoUrlPrefix(generateUrl);
responseVO.setVideoMaxSize(102400000);
responseVO.setVideoAllowFiles(Arrays.asList(videoAllowFiles));
responseVO.setFileActionName("uploadfile");
responseVO.setFileFieldName("upfile");
responseVO.setFilePathFormat("/sharing/file/{time}{rand:6}");
responseVO.setFilePathFormat("/file/{time}{rand:6}");
responseVO.setFileUrlPrefix(generateUrl);
responseVO.setFileMaxSize(51200000);
responseVO.setFileAllowFiles(Arrays.asList(fileAllowFiles));
responseVO.setImageManagerActionName("listimage");
responseVO.setImageManagerListPath("/sharing/image/");
responseVO.setImageManagerListPath("/image/");
responseVO.setImageManagerListSize(20);
responseVO.setImageManagerUrlPrefix(generateUrl);
responseVO.setImageManagerInsertAlign("none");
String[] imageManagerAllowFiles = new String[]{".png", ".jpg", ".jpeg", ".gif", ".bmp"};
responseVO.setImageManagerAllowFiles(Arrays.asList(imageManagerAllowFiles));
responseVO.setFileManagerActionName("listfile");
responseVO.setFileManagerListPath("/sharing/file/");
responseVO.setFileManagerListPath("/file/");
responseVO.setFileManagerUrlPrefix(generateUrl);
responseVO.setFileManagerListSize(20);
responseVO.setFileManagerAllowFiles(Arrays.asList(fileAllowFiles));
......@@ -103,22 +103,22 @@ public class AgmsSharingServiceImpl implements AgmsSharingService {
String type = upfile.getOriginalFilename().substring(upfile.getOriginalFilename().indexOf(".") + 1);
byte[] bytes = upfile.getBytes();
InputStream in = new ByteArrayInputStream(bytes);
StringBuilder key = new StringBuilder("/sharing/");
StringBuilder key = new StringBuilder("sharing/");
String title;
Date date = new Date();
SimpleDateFormat sd = new SimpleDateFormat("yyyyMMddHHmmssSSS");
String nowTime = sd.format(date);
if (Arrays.asList(imageAllowFiles).contains(type)){
if (Arrays.asList(imageAllowFiles).contains("." + type)){
title = nowTime + (int)(Math.random()*1000000);
key.append("image/").append(title);
}else if (Arrays.asList(videoAllowFiles).contains(type)){
}else if (Arrays.asList(videoAllowFiles).contains("." + type)){
title = nowTime + (int)(Math.random()*1000000);
key.append("video/").append(title);
}else {
title = nowTime + (int)(Math.random()*1000000);
key.append("file/").append(title);
}
String putFileToOss = ossService.putFileToOss(null, key.toString(), in);
String putFileToOss = ossService.putFileToOss(null, key.toString() + "." + type, in);
responseVO.setState("SUCCESS");
responseVO.setUrl(putFileToOss);
responseVO.setTitle(title);
......
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