Browse Source

代码修改

LAPTOP-KB9HII50\70708 3 years ago
parent
commit
56c4c07544

+ 9 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/common/FileUploadController.java

@ -52,6 +52,8 @@ public class FileUploadController extends EnvelopRestEndpoint {
    private String fastdfs_file_url;
    @Autowired
    FileUploadService fileUploadService;
    @Autowired
    private FastDFSUtil fastDFSHelper;
    @Value("${testPattern.sign}")
    private String isClose;
@ -104,12 +106,18 @@ public class FileUploadController extends EnvelopRestEndpoint {
        // 得到文件的完整名称  xxx.txt
        String originalFilename = file.getOriginalFilename();
        //得到文件类型
        String fileName = originalFilename.substring(0, originalFilename.lastIndexOf("."));
        String fileType = originalFilename.substring(originalFilename.lastIndexOf(".") + 1).toLowerCase();
        if(StringUtils.isBlank(fileType)||!"doc、docx、pdf、xls、xlsx、ppt、pptx".contains(fileType)){
            return ObjEnvelop.getError("文件格式不支持");
        }
        InputStream inputStream = file.getInputStream();
        uploadVO = fileUploadService.uploadStream(inputStream,originalFilename,fastdfs_file_url);
        ObjectNode objectNode = fastDFSHelper.upload(inputStream, fileType, "");
        //解析返回的objectNode
        uploadVO.setFileName(fileName);
        uploadVO.setFileType(fileType);
        uploadVO.setFullUri(objectNode.get("fileId").toString().replaceAll("\"", ""));
        uploadVO.setFullUrl(fastdfs_file_url + objectNode.get("fileId").toString().replaceAll("\"", ""));
        return success("上传成功", uploadVO);
    }

+ 1 - 1
svr/svr-base/src/main/resources/bootstrap.yml

@ -1,6 +1,6 @@
spring:
  application:
    name: svr-base
    name: svr-base-ysj
  cloud:
    config:
      failFast: true