update 文件上传服务完成

This commit is contained in:
yyb 2025-04-17 17:47:03 +08:00
parent bcdbb2b538
commit de4788319b
4 changed files with 14 additions and 13 deletions

View File

@ -38,7 +38,7 @@ public class SysFileController
/**
* 文件上传请求
*/
@PostMapping("upload")
@PostMapping("/upload")
public R<SysFile> upload(MultipartFile file)
{
try

View File

@ -20,7 +20,7 @@ public class LocalSysFileServiceImpl implements ISysFileService
/**
* 资源映射路径 前缀
*/
@Value("${file.prefix")
@Value("${file.prefix}")
public String localFilePrefix;
/**

View File

@ -1,11 +1,5 @@
package com.m2pool.file.utils;
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.Objects;
import org.apache.commons.io.FilenameUtils;
import org.springframework.web.multipart.MultipartFile;
import com.m2pool.common.core.exception.file.FileNameLengthLimitExceededException;
import com.m2pool.common.core.exception.file.FileSizeLimitExceededException;
import com.m2pool.common.core.exception.file.InvalidExtensionException;
@ -13,8 +7,13 @@ import com.m2pool.common.core.utils.DateUtils;
import com.m2pool.common.core.utils.StringUtils;
import com.m2pool.common.core.utils.file.MimeTypeUtils;
import com.m2pool.common.core.utils.uuid.Seq;
import org.apache.commons.io.FilenameUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.sound.midi.Soundbank;
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.Objects;
/**
* 文件上传工具类
@ -81,6 +80,7 @@ public class FileUploadUtils
String absPath = getAbsoluteFile(baseDir, fileName).getAbsolutePath();
file.transferTo(Paths.get(absPath));
return getPathFileName(fileName);
}

View File

@ -1,18 +1,19 @@
# Tomcat
server:
port: 9300
port: 9504
# Spring
spring:
application:
# 应用名称
name: m2pool-file
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8808
namespace: m2_test
group: m2_test_group
config:
# 配置中心地址
server-addr: 127.0.0.1:8808
@ -22,8 +23,8 @@ spring:
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
file:
domain: https://www.m2pool.com
path: /var/www/html/web-test
domain: https://test.m2pool.com
path: /var/www/html/web_test
# img: /img
filepath: /home/ubuntu/web
prefix: /statics