String fileName = DateFormatUtils.format(new Date(), "yyyyMMddHHmmssSSS") + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf('.'), file.getOriginalFilename().length());
DateFormatUtils.format(new Date(), "yyyyMMddHHmmssSSS") = 20211229154329907 时间格式化(为了文件名不重复)
file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf('.'), file.getOriginalFilename().length()); 获取上传时源文件名 然后通过sub 获取文件后缀 .png
二者拼接就是真实存在服务器上的文件名
----
Files.write(Paths.get(path).normalize().toAbsolutePath(), file.getBytes(), StandardOpenOption.CREATE_NEW);
String path = generatePath(fileName);获取将要上传的文件全路径及文件名称
Files.write(Paths.get(path).normalize().toAbsolutePath(), file.getBytes(), StandardOpenOption.CREATE_NEW);往磁盘写入文件
Paths.get(path).normalize().toAbsolutePath() 文件全路径
file.getBytes() 文件流
StandardOpenOption.CREATE_NEW 写入文件为创建 也有apend添加之类的