新增接口

This commit is contained in:
haozq 2025-07-03 19:03:44 +08:00
parent c341a76ea0
commit 22b411ed98
2 changed files with 7 additions and 6 deletions

View File

@ -165,8 +165,8 @@ public class FileMongoServiceImpl {
* @throws Exception
*/
public FileExportVo saveBinaryFile(MultipartFile file) throws Exception {
String suffix = getFileSuffix(file);
InputStream input= file.getInputStream();
MongoFile mongoFile = mongoFileRepository.save(
MongoFile.builder()
.fileName(file.getOriginalFilename())
@ -175,10 +175,11 @@ public class FileMongoServiceImpl {
.contentType(file.getContentType())
.uploadDate(DateUtils.dateTimeNow())
.suffix(suffix)
.md5(Md5Util.getMd5(file.getInputStream()))
.md5(Md5Util.getMd5(input))
.build()
);
//必须关闭
input.close();
return new FileExportVo(mongoFile);
}
/**
@ -190,6 +191,7 @@ public class FileMongoServiceImpl {
*/
public FileExportVo saveGridFsFile(MultipartFile file) throws Exception {
String suffix = getFileSuffix(file);
InputStream input= file.getInputStream();
String gridFsId = this.storeFileToGridFs(file.getInputStream(), file.getContentType());
MongoFile mongoFile = mongoTemplate.save(
MongoFile.builder()
@ -198,11 +200,11 @@ public class FileMongoServiceImpl {
.contentType(file.getContentType())
.uploadDate(DateUtils.dateTimeNow())
.suffix(suffix)
.md5(Md5Util.getMd5(file.getInputStream()))
.md5(Md5Util.getMd5(input))
.gridFsId(gridFsId)
.build()
);
input.close();
return new FileExportVo(mongoFile);
}
public FileExportVo saveBinaryFile(File file) throws Exception {

View File

@ -9,7 +9,6 @@ spring:
discovery:
server-addr: 127.0.0.1:18848
namespace: robot
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver