新增接口
This commit is contained in:
parent
c341a76ea0
commit
22b411ed98
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue