huangzhiyong 6 سال پیش
والد
کامیت
1c56274ebc

+ 11 - 9
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/dfs/FastDFSController.java

@ -46,8 +46,10 @@ public class FastDFSController extends EnvelopRestEndpoint {
    @Autowired
    private FileResourceService fileResourceService;
    @Value("${img.path}")
    private String img_path;
    @Value("${img.path1}")
    private String img_path1;
    @Value("${img.path2}")
    private String img_path2;
    private final ResourceLoader resourceLoader;
@ -199,7 +201,7 @@ public class FastDFSController extends EnvelopRestEndpoint {
            @ApiParam(name = "id", value = "id", required = true)
            @RequestParam(value = "id") String id) throws Exception {
        FileResource fileResource = fileResourceService.findById(id);
        String storagePath = fileResource.getStoragePath();
        String storagePath = img_path1+fileResource.getStoragePath();
        byte[] bytes = load(storagePath);
        String fileStream = new String(Base64.getEncoder().encode(bytes));
        if (!StringUtils.isEmpty(fileStream)) {
@ -220,9 +222,9 @@ public class FastDFSController extends EnvelopRestEndpoint {
    public Envelop downloadByPath(
            @ApiParam(name = "path", value = "文件路径", required = true)
            @RequestParam(value = "path") String path) throws Exception {
        if (path.split(":").length < 2) {
            return failed("参数有误");
        }
//        if (path.split(":").length < 2) {
//            return failed("参数有误");
//        }
        byte[] bytes = load(path);
        String fileStream = new String(Base64.getEncoder().encode(bytes));
        if (!StringUtils.isEmpty(fileStream)) {
@ -239,10 +241,10 @@ public class FastDFSController extends EnvelopRestEndpoint {
     */
    public String upload(InputStream inputStream, String fileName) {
        OutputStream outputStream = null;
        String path1 = img_path + "/" + fileName;
        String path1 = img_path1+img_path2 + "/" + fileName;
        try {
            //文件源
            File files = new File(img_path);
            File files = new File(img_path1+img_path2);
            if (!files.exists()) {//判断文件夹是否创建,没有创建则创建新文件夹
                files.mkdirs();
            }
@ -269,7 +271,7 @@ public class FastDFSController extends EnvelopRestEndpoint {
                e.printStackTrace();
            }
        }
        return path1;
        return img_path2 + "/" + fileName;
    }
    /**

+ 9 - 4
svr/svr-healthy-house/src/main/resources/application.yml

@ -86,8 +86,9 @@ fastDFS:
jw:
  smsUrl: http://svr-base:10020/sms_gateway/send
img:
  path: E:/tryfile/upload/img/
#  path: /root/uploadFiles/group1
#  path1: E:/tryfile/upload/img
  path1: /data/upload/img/
  path2: /group1
---
spring:
@ -105,7 +106,9 @@ fastDFS:
jw:
  smsUrl: http://svr-base:10020/sms_gateway/send
img:
  path: /data/upload/img/
#  path1: E:/tryfile/upload/img
  path1: /data/upload/img/
  path2: /group1
---
spring:
  profiles: prod
@ -122,4 +125,6 @@ fastDFS:
jw:
  smsUrl: http://svr-base:10020/sms_gateway/send
img:
  path: /data/upload/img/
#  path1: E:/tryfile/upload/img
  path1: /data/upload/img/
  path2: /group1