zoukankan      html  css  js  c++  java
  • 2021.4.30 团队冲刺第三天

    今天整上传的功能

    这东西的基础是昨天的路径,把东西拆了然后再赋值给一个对象

    public class Upload {
    static {
    System.out.println("run this");
    }
    private static ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
    private static ImgService imgService = (ImgService) applicationContext.getBean("ImgServiceImpl");

    public static boolean uploadOne(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;
    }

    }
    }
  • 相关阅读:
    贪婪算法、递归计算、动态规划背包问题
    递归、动态规划计算斐波那契数列
    用于确定两个字符串最长公共子串的函数
    快速排序算法
    顺序、二分查找文本数据
    MyBatis面试题
    Spring面试题
    SpringMvc面试题
    jsp和servlet面试
    EJB的理解
  • 原文地址:https://www.cnblogs.com/buxiang-Christina/p/14909196.html
Copyright © 2011-2022 走看看