zoukankan      html  css  js  c++  java
  • 2021.5.1 团队冲刺第四天

    今天整输出图片

    还是根据路径,只不过路径是需要自己组装的

    public class Display {
    private static ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
    private static ImgService imgService = (ImgService) applicationContext.getBean("ImgServiceImpl");
    public static boolean displayImg(MultipartFile file){
    try {
    String path = CreatPath.creatPath(file);
    String hash = CreatPath.creatName();
    String name = file.getOriginalFilename();//上传文件的真实名称
    String suffixName = name.substring(name.lastIndexOf("."));//获取后缀名
    String fileName = hash + suffixName;
    File filepath = new File(path, fileName);
    ImgObject imgObject = new ImgObject(hash, path, name, staticConfig.UserMail, "nomal");
    imgService.addImg(imgObject);
    if (!filepath.getParentFile().exists()) {
    filepath.getParentFile().mkdirs();
    }
    File tempFile = new File(path + fileName);
    file.transferTo(tempFile);
    return true;
    } catch (Exception e) {
    return false;
    }
    }
    }
  • 相关阅读:
    10-3 集合之Set
    【Angular】排序
    【Mongous】
    【验证码】
    爬虫
    【DOM】
    年月日
    【Mocha】
    【Test】
    洛谷——P1823 音乐会的等待
  • 原文地址:https://www.cnblogs.com/buxiang-Christina/p/14909255.html
Copyright © 2011-2022 走看看