springboot文件上传、下载、在线打开以及删除的控制器层
@Controller
@RequestMapping("file")
public class FileController {
@Autowired
private FilesService filesService;
@PostMapping("upload")
public String upload(MultipartFile aaa,HttpSession session) throws IOException {
User user= (User) session.getAttribute("user1");
//获取文件原始名称
String oldFileName =aaa.getOriginalFilename();
//获取文件后缀
String extension="."+ FilenameUtils.getExtension(aaa.getOriginalFilename());
//生成新的文件名称
String newFileName=new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())+ UUID.randomUUID().toString().replace("-"," ")+extension;
//获取文件大小
long size=aaa.getSize();
//文件类型
String type=aaa.getContentType();
//文件路径
String realPath= "D:\\学习\\spring练习\\files\\src\\