保存进度!
This commit is contained in:
parent
1f988323d4
commit
c568da745f
|
@ -2,7 +2,7 @@
|
|||
* @Author: Kane
|
||||
* @Date: 2023-01-22 23:11:26
|
||||
* @LastEditors: Kane
|
||||
* @LastEditTime: 2023-01-23 23:22:10
|
||||
* @LastEditTime: 2023-01-24 00:35:02
|
||||
* @FilePath: \AdminSys\src\main\java\com\cpic\xim\web\controllers\FileUpload\FileUpload.java
|
||||
* @Description: 用于接受上传文件的Controller。
|
||||
*
|
||||
|
@ -24,6 +24,13 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
@RequestMapping( path = "/file" )
|
||||
public class FileUpload
|
||||
{
|
||||
/*****************************************************
|
||||
* 接收上传文件,并保存到临时目录:
|
||||
* 1、临时目录下再用sessionID作为子目录保存文件。
|
||||
* 2、保存时不更改文件名,会覆盖同名文件。
|
||||
* 3、MultipartFile参数形参名称必须和请求form中file标签的name属性一致,否则值为null。
|
||||
* 4、返回值为接收结果和文件保存路径。
|
||||
*****************************************************/
|
||||
@RequestMapping( path = "/file-upload.do" )
|
||||
@ResponseBody
|
||||
public FileUploadResult getUploadFile( @RequestParam( "task-name" ) String taskName,
|
||||
|
@ -35,10 +42,13 @@ public class FileUpload
|
|||
Vector<String> fileNames = new Vector<String>();
|
||||
int fileCount = files.length;
|
||||
|
||||
// 防御验证
|
||||
if ( files.length == 0 )
|
||||
{
|
||||
result.setSuccess( false );
|
||||
result.setMessage( "此接口用于上传文件!" );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
result.setSuccess( true );
|
||||
|
@ -46,9 +56,17 @@ public class FileUpload
|
|||
|
||||
for ( MultipartFile file : files )
|
||||
{
|
||||
String fileName = file.getName();
|
||||
if ( file.isEmpty() )
|
||||
{
|
||||
// 文件长度位0,跳过
|
||||
continue;
|
||||
}
|
||||
|
||||
fileNames.add( fileName );
|
||||
String filePath =
|
||||
request.getServletContext().getRealPath( "/temp/upload/" + sessionID );
|
||||
String fileName = file.getOriginalFilename();
|
||||
|
||||
fileNames.add( file.getOriginalFilename() );
|
||||
}
|
||||
|
||||
result.setFileList( fileNames );
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @Author: Kane
|
||||
* @Date: 2023-01-12 15:01:22
|
||||
* @LastEditors: Kane
|
||||
* @LastEditTime: 2023-01-24 00:07:36
|
||||
* @LastEditTime: 2023-01-24 00:21:51
|
||||
* @FilePath: \AdminSys\src\main\java\com\cpic\xim\web\filters\token\TokenFilter.java
|
||||
* @Description: 用于检查token的过滤器
|
||||
*
|
||||
|
@ -23,7 +23,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
public class TokenFilter implements Filter
|
||||
{
|
||||
/*****************************************************
|
||||
*
|
||||
* 对请求的token进行验证。
|
||||
*****************************************************/
|
||||
@Override
|
||||
public void doFilter( ServletRequest req, ServletResponse resp, FilterChain chain )
|
||||
|
|
Loading…
Reference in New Issue