🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
上传下载只提供后台方法,上传文件记录会记录到TD_M_FILE表 ``` @RestController @RequestMapping("/fileserver") public class FileController extends BaseController{ @Resource(name="fileService") private FileService fileService; /** * 上传文件 * @param request */ @RequestMapping(value = "/upload") public void upload(MultipartHttpServletRequest request) throws Exception{ List<MultipartFile> files = FileUtil.getUpFiles(request); fileService.upFiles(files); } /** * 根据文件ID下载文件 * @param response * @param fileId */ @RequestMapping(value = "/down/{fileId}") public void down(HttpServletResponse response, @PathVariable String fileId) throws Exception{ TdMFile tdMFile = fileService.queryFileInfo(fileId); if(tdMFile == null){ common.error("Error: file[" + fileId + "]Does not exist."); } String fullName = tdMFile.getFilePath() + File.separator + tdMFile.getFileId(); String realName = tdMFile.getFileName(); FileUtil.downFile(response, fullName, realName); } /** * 根据文件ID显示文件 * @param response * @param fileId */ @RequestMapping(value = "/show/{fileId}") public void show(HttpServletResponse response, @PathVariable String fileId) throws Exception{ TdMFile tdMFile = fileService.queryFileInfo(fileId); if(tdMFile == null){ common.error("Error: file[" + fileId + "]Does not exist."); } String fullName = tdMFile.getFilePath() + File.separator + tdMFile.getFileId(); String realName = tdMFile.getFileName(); FileUtil.showFile(response, fullName, realName); } } ```