From 9a1593ad184cd28282bf46f1acb259138271766e Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期二, 09 十二月 2025 09:52:47 +0800
Subject: [PATCH] init
---
ruoyi-common/src/main/java/com/ruoyi/common/core/controller/FileController.java | 100 +++++++++++++++++++++++++-------------------------
1 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/FileController.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/FileController.java
index 01ade56..0538305 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/FileController.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/FileController.java
@@ -87,56 +87,56 @@
// return fileUploadConfig.getQrLocation() + TimeDir +"\\"+ fileName;
// }
- @ApiOperation(value = "单文件上传", notes = "单文件上传,rename 默认不重命名")
- @PostMapping(value = "strUpload", headers = "content-type=multipart/form-data")
- public String strUpload(@RequestParam(value = "file") MultipartFile mf,@RequestParam(value = "fileName")String fileName) throws IOException {
- if (mf.isEmpty()) {
- return "请传入文件!";
- }
- String TimeDir =new SimpleDateFormat("yyyy-MM-dd").format(new Date());
- String realPath = "C:\\Users\\Admin\\Desktop\\qrcode\\" + TimeDir;
- File file = new File(realPath);
- // 没有目录就创建
- if (!file.exists()) {
- file.mkdirs();
- }
- File targetFile = new File(realPath, fileName);//目标文件
- //开始从源文件拷贝到目标文件
- //传图片一步到位
- mf.transferTo(targetFile);
- //拼接数据
- return TimeDir +"/"+ fileName;
- }
-
- @ApiOperation(value = "单文件上传(覆盖服务器原文件)", notes = "单文件上传,rename 默认不重命名")
- @PostMapping(value = "test/upload", headers = "content-type=multipart/form-data")
- public AjaxResult uploadTest(@RequestParam(value = "file") MultipartFile mf) throws IOException {
- if (mf.isEmpty()) {
- return AjaxResult.error("请传入文件!");
- }
- String TimeDir = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
- String realPath = fileUploadConfig.getLocation() + "2021-11-17";
- File file = new File(realPath);
- // 没有目录就创建
- if (!file.exists()) {
- file.mkdirs();
- }
- // 判断文件大小
- String filename = "6u2mGlqHkeE75e2ab51b4a03c6982ff7d68f4c024d43.jpg";
- // 获取文件后缀
- String ext = filename.substring(filename.lastIndexOf("."), filename.length());
- // 检查文件类型
- if (!fileUploadConfig.getAllowExt().contains(ext)) {
- return AjaxResult.error("上传文件格式不正确,仅支持" + fileUploadConfig.getAllowExt());
- }
- File targetFile = new File(realPath, filename);//目标文件
- //开始从源文件拷贝到目标文件
- //传图片一步到位
- mf.transferTo(targetFile);
- //拼接数据
- String imgstr = fileUploadConfig.getAccessPath() + "2021-11-17" + "/" + filename;
- return AjaxResult.success(imgstr);
- }
+// @ApiOperation(value = "单文件上传", notes = "单文件上传,rename 默认不重命名")
+// @PostMapping(value = "strUpload", headers = "content-type=multipart/form-data")
+// public String strUpload(@RequestParam(value = "file") MultipartFile mf,@RequestParam(value = "fileName")String fileName) throws IOException {
+// if (mf.isEmpty()) {
+// return "请传入文件!";
+// }
+// String TimeDir =new SimpleDateFormat("yyyy-MM-dd").format(new Date());
+// String realPath = "C:\\Users\\Admin\\Desktop\\qrcode\\" + TimeDir;
+// File file = new File(realPath);
+// // 没有目录就创建
+// if (!file.exists()) {
+// file.mkdirs();
+// }
+// File targetFile = new File(realPath, fileName);//目标文件
+// //开始从源文件拷贝到目标文件
+// //传图片一步到位
+// mf.transferTo(targetFile);
+// //拼接数据
+// return TimeDir +"/"+ fileName;
+// }
+//
+// @ApiOperation(value = "单文件上传(覆盖服务器原文件)", notes = "单文件上传,rename 默认不重命名")
+// @PostMapping(value = "test/upload", headers = "content-type=multipart/form-data")
+// public AjaxResult uploadTest(@RequestParam(value = "file") MultipartFile mf) throws IOException {
+// if (mf.isEmpty()) {
+// return AjaxResult.error("请传入文件!");
+// }
+// String TimeDir = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
+// String realPath = fileUploadConfig.getLocation() + "2021-11-17";
+// File file = new File(realPath);
+// // 没有目录就创建
+// if (!file.exists()) {
+// file.mkdirs();
+// }
+// // 判断文件大小
+// String filename = "6u2mGlqHkeE75e2ab51b4a03c6982ff7d68f4c024d43.jpg";
+// // 获取文件后缀
+// String ext = filename.substring(filename.lastIndexOf("."), filename.length());
+// // 检查文件类型
+// if (!fileUploadConfig.getAllowExt().contains(ext)) {
+// return AjaxResult.error("上传文件格式不正确,仅支持" + fileUploadConfig.getAllowExt());
+// }
+// File targetFile = new File(realPath, filename);//目标文件
+// //开始从源文件拷贝到目标文件
+// //传图片一步到位
+// mf.transferTo(targetFile);
+// //拼接数据
+// String imgstr = fileUploadConfig.getAccessPath() + "2021-11-17" + "/" + filename;
+// return AjaxResult.success(imgstr);
+// }
}
--
Gitblit v1.7.1