保存进度!
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
* @Author: Kane Wang <wangkane@qq.com>
|
* @Author: Kane Wang <wangkane@qq.com>
|
||||||
* @Date: 2025-10-16 09:46:42
|
* @Date: 2025-10-16 09:46:42
|
||||||
* @LastEditors: Kane Wang
|
* @LastEditors: Kane Wang
|
||||||
* @LastModified: 2025-11-13 15:25:07
|
* @LastModified: 2025-11-14 11:17:39
|
||||||
* @FilePath: src/main/java/com/cpic/xim/utils/files/SaveUploadFile.java
|
* @FilePath: src/main/java/com/cpic/xim/utils/files/SaveUploadFile.java
|
||||||
* @Description:
|
* @Description:
|
||||||
*
|
*
|
||||||
@@ -80,6 +80,13 @@ public class SaveUploadFile
|
|||||||
return savedFiles;
|
return savedFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将files参数中上传的文件,保存到tempFilePath指定的路径,文件名加上毫秒数避免重复。
|
||||||
|
* @param files
|
||||||
|
* @param tempFilePath
|
||||||
|
* @return 返回UploadedFile对象数组
|
||||||
|
* @throws ProcessUploadedFileException
|
||||||
|
*/
|
||||||
public static Vector<UploadedFile> saveUploadFiles(
|
public static Vector<UploadedFile> saveUploadFiles(
|
||||||
MultipartFile[] files,
|
MultipartFile[] files,
|
||||||
String tempFilePath
|
String tempFilePath
|
||||||
@@ -143,6 +150,20 @@ public class SaveUploadFile
|
|||||||
String newFilePath
|
String newFilePath
|
||||||
) throws MoveUploadedFileException
|
) throws MoveUploadedFileException
|
||||||
{
|
{
|
||||||
|
// 防御性验证
|
||||||
|
File originFile = new File( originFilePath );
|
||||||
|
File dest = new File( newFilePath );
|
||||||
|
|
||||||
|
// 文件如果不存在就抛出异常
|
||||||
|
if ( originFile.exists() == false )
|
||||||
|
{
|
||||||
|
throw new MoveUploadedFileException("文件不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ( originFile.renameTo(dest) == false )
|
||||||
|
{
|
||||||
|
throw new MoveUploadedFileException("移动文件失败!" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class FileUpload
|
|||||||
*/
|
*/
|
||||||
@RequestMapping( path = "/file-upload.do" )
|
@RequestMapping( path = "/file-upload.do" )
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public FileUploadResult saveUploadFile(
|
public UploadFileResult saveUploadFile(
|
||||||
@RequestParam( "file-name" ) String fileName,
|
@RequestParam( "file-name" ) String fileName,
|
||||||
@RequestParam( "files" ) MultipartFile file,
|
@RequestParam( "files" ) MultipartFile file,
|
||||||
HttpServletRequest request
|
HttpServletRequest request
|
||||||
@@ -52,7 +52,7 @@ public class FileUpload
|
|||||||
{
|
{
|
||||||
// session id用来创建临时目录,避免重复
|
// session id用来创建临时目录,避免重复
|
||||||
String sessionID = request.getSession().getId();
|
String sessionID = request.getSession().getId();
|
||||||
FileUploadResult result = new FileUploadResult();
|
UploadFileResult result = new UploadFileResult();
|
||||||
MultipartFile[] files = new MultipartFile[1];
|
MultipartFile[] files = new MultipartFile[1];
|
||||||
|
|
||||||
result.setSuccess( true );
|
result.setSuccess( true );
|
||||||
@@ -86,4 +86,6 @@ public class FileUpload
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
/**
|
||||||
|
* @Author: Kane Wang <wangkane@qq.com>
|
||||||
|
* @Date: 2025-11-17 17:49:58
|
||||||
|
* @LastEditors: Kane Wang
|
||||||
|
* @LastModified: 2025-11-17 18:11:27
|
||||||
|
* @FilePath: src/main/java/com/cpic/xim/web/controllers/fileupload/MoveFileRequest.java
|
||||||
|
* @Description:
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025 by Kane All rights reserved
|
||||||
|
*/
|
||||||
|
package com.cpic.xim.web.controllers.fileupload;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
public class MoveFileRequest
|
||||||
|
{
|
||||||
|
@JsonProperty("origin-file-path")
|
||||||
|
private String originFilePath;
|
||||||
|
|
||||||
|
@JsonProperty("dest-file-path")
|
||||||
|
private String destFilePath;
|
||||||
|
|
||||||
|
public MoveFileRequest()
|
||||||
|
{
|
||||||
|
originFilePath = "";
|
||||||
|
destFilePath = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public MoveFileRequest( String originFilePath, String destFilePath )
|
||||||
|
{
|
||||||
|
this.originFilePath = originFilePath;
|
||||||
|
this.destFilePath = destFilePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOriginFilePath()
|
||||||
|
{
|
||||||
|
return originFilePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOriginFilePath( String originFilePath )
|
||||||
|
{
|
||||||
|
this.originFilePath = originFilePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDestFilePath()
|
||||||
|
{
|
||||||
|
return destFilePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDestFilePath( String destFilePath )
|
||||||
|
{
|
||||||
|
this.destFilePath = destFilePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
/**
|
||||||
|
* @Author: Kane Wang <wangkane@qq.com>
|
||||||
|
* @Date: 2025-11-17 17:31:15
|
||||||
|
* @LastEditors: Kane Wang
|
||||||
|
* @LastModified: 2025-11-17 17:31:16
|
||||||
|
* @FilePath: src/main/java/com/cpic/xim/web/controllers/fileupload/MoveFileResult.java
|
||||||
|
* @Description:
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025 by Kane All rights reserved
|
||||||
|
*/
|
||||||
|
package com.cpic.xim.web.controllers.fileupload;
|
||||||
|
|
||||||
|
import com.cpic.xim.web.controllers.QueryResponse;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
public class MoveFileResult extends QueryResponse
|
||||||
|
{
|
||||||
|
|
||||||
|
@JsonProperty("new-file-path")
|
||||||
|
private String newFilePath;
|
||||||
|
|
||||||
|
public MoveFileResult()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MoveFileResult(
|
||||||
|
boolean success,
|
||||||
|
String message,
|
||||||
|
String newFilePath
|
||||||
|
)
|
||||||
|
{
|
||||||
|
super( success, message );
|
||||||
|
|
||||||
|
this.newFilePath = newFilePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNewFilePath()
|
||||||
|
{
|
||||||
|
return newFilePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNewFilePath( String newFilePath )
|
||||||
|
{
|
||||||
|
this.newFilePath = newFilePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,9 +23,9 @@ import com.cpic.xim.web.controllers.QueryResponse;
|
|||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
@SuppressWarnings( "unused" )
|
@SuppressWarnings( "unused" )
|
||||||
public class FileUploadResult extends QueryResponse
|
public class UploadFileResult extends QueryResponse
|
||||||
{
|
{
|
||||||
public FileUploadResult()
|
public UploadFileResult()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ public class FileUploadResult extends QueryResponse
|
|||||||
* @param message 消息字符串
|
* @param message 消息字符串
|
||||||
* @param fileList 文件绝对路径字符串数组
|
* @param fileList 文件绝对路径字符串数组
|
||||||
*/
|
*/
|
||||||
public FileUploadResult(
|
public UploadFileResult(
|
||||||
boolean success,
|
boolean success,
|
||||||
String message,
|
String message,
|
||||||
Vector<UploadedFile> fileList
|
Vector<UploadedFile> fileList
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@element-plus/icons-vue": "^2.3.2",
|
"@element-plus/icons-vue": "^2.3.2",
|
||||||
"@stylistic/eslint-plugin": "^5.5.0",
|
"@stylistic/eslint-plugin": "^5.5.0",
|
||||||
"@types/node": "^24.9.2",
|
"@types/node": "^24.10.1",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.46.4",
|
"@typescript-eslint/eslint-plugin": "^8.46.4",
|
||||||
"@typescript-eslint/parser": "^8.46.4",
|
"@typescript-eslint/parser": "^8.46.4",
|
||||||
"@vitejs/plugin-vue": "^6.0.1",
|
"@vitejs/plugin-vue": "^6.0.1",
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
"@vue-office/pdf": "^2.0.10",
|
"@vue-office/pdf": "^2.0.10",
|
||||||
"@vue/tsconfig": "^0.8.1",
|
"@vue/tsconfig": "^0.8.1",
|
||||||
"axios": "^1.13.2",
|
"axios": "^1.13.2",
|
||||||
"element-plus": "^2.11.7",
|
"element-plus": "^2.11.8",
|
||||||
"eslint": "^9.39.1",
|
"eslint": "^9.39.1",
|
||||||
"eslint-plugin-vue": "^10.5.1",
|
"eslint-plugin-vue": "^10.5.1",
|
||||||
"path": "^0.12.7",
|
"path": "^0.12.7",
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
"vue-demi": "^0.14.10",
|
"vue-demi": "^0.14.10",
|
||||||
"vue-eslint-parser": "^10.2.0",
|
"vue-eslint-parser": "^10.2.0",
|
||||||
"vue-pdf-embed": "^2.1.3",
|
"vue-pdf-embed": "^2.1.3",
|
||||||
"vue-tsc": "^3.1.3"
|
"vue-tsc": "^3.1.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@babel/helper-string-parser": {
|
"node_modules/@babel/helper-string-parser": {
|
||||||
@@ -1744,9 +1744,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "24.9.2",
|
"version": "24.10.1",
|
||||||
"resolved": "https://registry.npmmirror.com/@types/node/-/node-24.9.2.tgz",
|
"resolved": "https://registry.npmmirror.com/@types/node/-/node-24.10.1.tgz",
|
||||||
"integrity": "sha512-uWN8YqxXxqFMX2RqGOrumsKeti4LlmIMIyV0lgut4jx7KQBcBiW6vkDtIBvHnHIquwNfJhk8v2OtmO8zXWHfPA==",
|
"integrity": "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
"peer": true,
|
||||||
@@ -2154,9 +2154,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@vue/language-core": {
|
"node_modules/@vue/language-core": {
|
||||||
"version": "3.1.3",
|
"version": "3.1.4",
|
||||||
"resolved": "https://registry.npmmirror.com/@vue/language-core/-/language-core-3.1.3.tgz",
|
"resolved": "https://registry.npmmirror.com/@vue/language-core/-/language-core-3.1.4.tgz",
|
||||||
"integrity": "sha512-KpR1F/eGAG9D1RZ0/T6zWJs6dh/pRLfY5WupecyYKJ1fjVmDMgTPw9wXmKv2rBjo4zCJiOSiyB8BDP1OUwpMEA==",
|
"integrity": "sha512-n/58wm8SkmoxMWkUNUH/PwoovWe4hmdyPJU2ouldr3EPi1MLoS7iDN46je8CsP95SnVBs2axInzRglPNKvqMcg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -2622,9 +2622,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/element-plus": {
|
"node_modules/element-plus": {
|
||||||
"version": "2.11.7",
|
"version": "2.11.8",
|
||||||
"resolved": "https://registry.npmmirror.com/element-plus/-/element-plus-2.11.7.tgz",
|
"resolved": "https://registry.npmmirror.com/element-plus/-/element-plus-2.11.8.tgz",
|
||||||
"integrity": "sha512-Bh47wuzsqaNBNDkbtlOlZER1cGcOB8GsXp/+C9b95MOrk0wvoHUV4NKKK7xMkfYNFYdYysQ752oMhnExgAL6+g==",
|
"integrity": "sha512-2wzSj2uubFU1f0t/gHkkE1d09mUgV18fSZX5excw3Ar6hyWcxph4E57U8dgYLDt7HwkKYv1BiqPyBdy0WqWlOA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -4477,14 +4477,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/vue-tsc": {
|
"node_modules/vue-tsc": {
|
||||||
"version": "3.1.3",
|
"version": "3.1.4",
|
||||||
"resolved": "https://registry.npmmirror.com/vue-tsc/-/vue-tsc-3.1.3.tgz",
|
"resolved": "https://registry.npmmirror.com/vue-tsc/-/vue-tsc-3.1.4.tgz",
|
||||||
"integrity": "sha512-StMNfZHwPIXQgY3KxPKM0Jsoc8b46mDV3Fn2UlHCBIwRJApjqrSwqeMYgWf0zpN+g857y74pv7GWuBm+UqQe1w==",
|
"integrity": "sha512-GsRJxttj4WkmXW/zDwYPGMJAN3np/4jTzoDFQTpTsI5Vg/JKMWamBwamlmLihgSVHO66y9P7GX+uoliYxeI4Hw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@volar/typescript": "2.4.23",
|
"@volar/typescript": "2.4.23",
|
||||||
"@vue/language-core": "3.1.3"
|
"@vue/language-core": "3.1.4"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"vue-tsc": "bin/vue-tsc.js"
|
"vue-tsc": "bin/vue-tsc.js"
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@element-plus/icons-vue": "^2.3.2",
|
"@element-plus/icons-vue": "^2.3.2",
|
||||||
"@stylistic/eslint-plugin": "^5.5.0",
|
"@stylistic/eslint-plugin": "^5.5.0",
|
||||||
"@types/node": "^24.9.2",
|
"@types/node": "^24.10.1",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.46.4",
|
"@typescript-eslint/eslint-plugin": "^8.46.4",
|
||||||
"@typescript-eslint/parser": "^8.46.4",
|
"@typescript-eslint/parser": "^8.46.4",
|
||||||
"@vitejs/plugin-vue": "^6.0.1",
|
"@vitejs/plugin-vue": "^6.0.1",
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
"@vue-office/pdf": "^2.0.10",
|
"@vue-office/pdf": "^2.0.10",
|
||||||
"@vue/tsconfig": "^0.8.1",
|
"@vue/tsconfig": "^0.8.1",
|
||||||
"axios": "^1.13.2",
|
"axios": "^1.13.2",
|
||||||
"element-plus": "^2.11.7",
|
"element-plus": "^2.11.8",
|
||||||
"eslint": "^9.39.1",
|
"eslint": "^9.39.1",
|
||||||
"eslint-plugin-vue": "^10.5.1",
|
"eslint-plugin-vue": "^10.5.1",
|
||||||
"path": "^0.12.7",
|
"path": "^0.12.7",
|
||||||
@@ -35,6 +35,6 @@
|
|||||||
"vue-demi": "^0.14.10",
|
"vue-demi": "^0.14.10",
|
||||||
"vue-eslint-parser": "^10.2.0",
|
"vue-eslint-parser": "^10.2.0",
|
||||||
"vue-pdf-embed": "^2.1.3",
|
"vue-pdf-embed": "^2.1.3",
|
||||||
"vue-tsc": "^3.1.3"
|
"vue-tsc": "^3.1.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user