文件修改
This commit is contained in:
+4
-2
@@ -32,6 +32,8 @@ public class OSSFileServiceImpl extends ServiceImpl<OSSFileMapper, OSSFile> impl
|
||||
|
||||
@Value(value = "${jero.path.upload}")
|
||||
private String uploadpath;
|
||||
@Value(value = "${jero.path.uploadCos}")
|
||||
private String uploadCospath;
|
||||
|
||||
/**
|
||||
* 文件后缀黑名单
|
||||
@@ -188,7 +190,7 @@ public class OSSFileServiceImpl extends ServiceImpl<OSSFileMapper, OSSFile> impl
|
||||
|
||||
OSSFile oSSFile = new OSSFile();
|
||||
try {
|
||||
String ctxPath = uploadpath;
|
||||
String ctxPath = uploadCospath;
|
||||
String fileName = null;
|
||||
String fileType = null;
|
||||
|
||||
@@ -285,7 +287,7 @@ public class OSSFileServiceImpl extends ServiceImpl<OSSFileMapper, OSSFile> impl
|
||||
|
||||
OSSFile oSSFile = new OSSFile();
|
||||
try {
|
||||
String ctxPath = uploadpath;
|
||||
String ctxPath = uploadCospath;
|
||||
String fileName = null;
|
||||
String fileType = null;
|
||||
File file = new File(ctxPath + File.separator + bizPath + File.separator);
|
||||
|
||||
+4
-4
@@ -167,8 +167,8 @@ public class CommonController {
|
||||
// bizPath = "";
|
||||
// }
|
||||
}
|
||||
OSSFile oSSFile = ossFileService.uploadLocal(file, bizPath,state,cut);
|
||||
// OSSFile oSSFile = ossFileService.uploadLocalOfCos(file, bizPath,state,cut); // 切换cos
|
||||
// OSSFile oSSFile = ossFileService.uploadLocal(file, bizPath,state,cut);
|
||||
OSSFile oSSFile = ossFileService.uploadLocalOfCos(file, bizPath,state,cut); // 切换cos
|
||||
if (oConvertUtils.isNotEmpty(oSSFile)) {
|
||||
result.setResult(oSSFile);
|
||||
result.setSuccess(true);
|
||||
@@ -343,7 +343,7 @@ public class CommonController {
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
// @GetMapping(value = "/downLoadFile")
|
||||
@GetMapping(value = "/downLoadFile")
|
||||
public void downLoadFromCos(String id,HttpServletRequest request, HttpServletResponse response) {
|
||||
if(StringUtils.isBlank(id)){
|
||||
throw new JeroBootException("参数信息不全");
|
||||
@@ -408,7 +408,7 @@ public class CommonController {
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@GetMapping(value = "/downLoadFile")
|
||||
// @GetMapping(value = "/downLoadFile")
|
||||
public void downLoadFile(String id,HttpServletRequest request, HttpServletResponse response) {
|
||||
// 查询数据表数据是否存在
|
||||
LambdaQueryWrapper<OSSFile> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
+48
-21
@@ -23,6 +23,7 @@ import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.query.QueryRuleEnum;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.common.util.DateUtils;
|
||||
import com.jero.common.util.oss.CosBootUtil;
|
||||
import com.jero.generater.modules.online.cgform.entity.OnlCgformField;
|
||||
import com.jero.generater.modules.online.cgform.service.impl.OnlCgformFieldServiceImpl;
|
||||
import com.jero.modules.collection.entity.OnlCgformCollection;
|
||||
@@ -106,6 +107,7 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
@@ -3905,7 +3907,15 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
file.mkdirs();
|
||||
for (OSSFile ossFile : fileInfosList) {
|
||||
String url = ossFile.getUrl();
|
||||
copyFile(url, fileNowPath + File.separator + ossFile.getFileName());
|
||||
//判断文件是否存在
|
||||
if(StringUtils.isNotBlank(url)){
|
||||
//判断文件是否存在
|
||||
boolean b = CosBootUtil.doesObjectExist(url);
|
||||
if(b){
|
||||
InputStream download = CosBootUtil.download(url);
|
||||
copyFile(download, fileNowPath + File.separator + ossFile.getFileName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4353,32 +4363,49 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
|
||||
}
|
||||
|
||||
public static void copyFile(String oldFile, String newFile) throws IOException {
|
||||
|
||||
public static void copyFile(InputStream in, String newFile) throws IOException {
|
||||
File file2 = new File(newFile);
|
||||
if (!file2.exists()) {
|
||||
file2.createNewFile();
|
||||
}
|
||||
// file2.mkdir();
|
||||
File temp = new File(oldFile);
|
||||
|
||||
if (temp.isFile()) {
|
||||
try (FileInputStream in = new FileInputStream(temp);
|
||||
FileOutputStream ou = new FileOutputStream(newFile);) {
|
||||
|
||||
byte[] bs = new byte[1024];
|
||||
int count = 0;
|
||||
while ((count = in.read(bs, 0, bs.length)) != -1) {
|
||||
ou.write(bs, 0, count);
|
||||
}
|
||||
ou.flush();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new IOException("复制文件失败!");
|
||||
try (FileOutputStream ou = new FileOutputStream(newFile);) {
|
||||
byte[] bs = new byte[1024];
|
||||
int count = 0;
|
||||
while ((count = in.read(bs, 0, bs.length)) != -1) {
|
||||
ou.write(bs, 0, count);
|
||||
}
|
||||
|
||||
ou.flush();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new IOException("复制文件失败!");
|
||||
}
|
||||
}
|
||||
// public static void copyFile(String oldFile, String newFile) throws IOException {
|
||||
//
|
||||
// File file2 = new File(newFile);
|
||||
// if (!file2.exists()) {
|
||||
// file2.createNewFile();
|
||||
// }
|
||||
//// file2.mkdir();
|
||||
// File temp = new File(oldFile);
|
||||
//
|
||||
// if (temp.isFile()) {
|
||||
// try (FileInputStream in = new FileInputStream(temp);
|
||||
// FileOutputStream ou = new FileOutputStream(newFile);) {
|
||||
//
|
||||
// byte[] bs = new byte[1024];
|
||||
// int count = 0;
|
||||
// while ((count = in.read(bs, 0, bs.length)) != -1) {
|
||||
// ou.write(bs, 0, count);
|
||||
// }
|
||||
// ou.flush();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// throw new IOException("复制文件失败!");
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* ocr识别调取已入库文件-中英文切换
|
||||
@@ -5203,7 +5230,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
MultipartFile multipartFile =
|
||||
new MockMultipartFile(nowFileList.get(0).getName(), nowFileList.get(0).getName(), "text/plain", input);
|
||||
//文件存入文件表
|
||||
OSSFile ossFile = iOSSFileService.uploadLocal(multipartFile, "", null,null);
|
||||
OSSFile ossFile = iOSSFileService.uploadLocalOfCos(multipartFile, "", null,null);
|
||||
if (ObjectUtils.isNotEmpty(ossFile)) {
|
||||
sb.append(ossFile.getId() + ",");
|
||||
}
|
||||
|
||||
+9
-2
@@ -14,6 +14,7 @@ import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.query.QueryGenerator;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.common.util.DateUtils;
|
||||
import com.jero.common.util.oss.CosBootUtil;
|
||||
import com.jero.modules.document.entity.BussDocumentLibraryEO;
|
||||
import com.jero.modules.document.service.IBussDocumentLibraryEOService;
|
||||
import com.jero.modules.dummy.entity.DummyInventoryBaseEO;
|
||||
@@ -1476,7 +1477,7 @@ public class DummyInventoryInfoEOServiceImpl extends ServiceImpl<DummyInventoryI
|
||||
MultipartFile multipartFile =
|
||||
new MockMultipartFile(nowFileList.get(0).getName(), nowFileList.get(0).getName(), "text/plain", input);
|
||||
//文件存入文件表
|
||||
OSSFile ossFile = iOSSFileService.uploadLocal(multipartFile, "", null,null);
|
||||
OSSFile ossFile = iOSSFileService.uploadLocalOfCos(multipartFile, "", null,null);
|
||||
if (ObjectUtils.isNotEmpty(ossFile)) {
|
||||
sb.append(ossFile.getId() + ",");
|
||||
}
|
||||
@@ -2204,7 +2205,13 @@ public class DummyInventoryInfoEOServiceImpl extends ServiceImpl<DummyInventoryI
|
||||
file.mkdirs();
|
||||
for (OSSFile ossFile : oSSFileList) {
|
||||
String url = ossFile.getUrl();
|
||||
copyFile(url, fileNowPath + File.separator + ossFile.getFileName());
|
||||
//判断文件是否存在
|
||||
boolean b = CosBootUtil.doesObjectExist(url);
|
||||
if (b) {
|
||||
//从腾讯云获取文件
|
||||
InputStream download = CosBootUtil.download(url);
|
||||
copyFile(download, fileNowPath + File.separator + ossFile.getFileName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-2
@@ -24,6 +24,7 @@ import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.query.QueryGenerator;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.common.util.DateUtils;
|
||||
import com.jero.common.util.oss.CosBootUtil;
|
||||
import com.jero.modules.document.entity.BussDocumentLibraryEO;
|
||||
import com.jero.modules.document.service.IBussDocumentLibraryEOService;
|
||||
import com.jero.modules.dummy.entity.DummyInventoryBaseEO;
|
||||
@@ -3974,7 +3975,7 @@ public class ProjectLawsInventoryEOServiceImpl extends ServiceImpl<ProjectLawsIn
|
||||
MultipartFile multipartFile =
|
||||
new MockMultipartFile(nowFileList.get(0).getName(), nowFileList.get(0).getName(), "text/plain", input);
|
||||
//文件存入文件表
|
||||
OSSFile ossFile = iOSSFileService.uploadLocal(multipartFile, "", null,null);
|
||||
OSSFile ossFile = iOSSFileService.uploadLocalOfCos(multipartFile, "", null,null);
|
||||
if (ObjectUtils.isNotEmpty(ossFile)) {
|
||||
sb.append(ossFile.getId() + ",");
|
||||
}
|
||||
@@ -4394,7 +4395,14 @@ public class ProjectLawsInventoryEOServiceImpl extends ServiceImpl<ProjectLawsIn
|
||||
file.mkdirs();
|
||||
for (OSSFile ossFile : oSSFileList) {
|
||||
String url = ossFile.getUrl();
|
||||
copyFile(url, fileNowPath + File.separator + ossFile.getFileName());
|
||||
if(StringUtils.isNotBlank(url)){
|
||||
//判断文件是否存在
|
||||
boolean b = CosBootUtil.doesObjectExist(url);
|
||||
if(b){
|
||||
InputStream download = CosBootUtil.download(url);
|
||||
copyFile(download, fileNowPath + File.separator + ossFile.getFileName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,6 +195,7 @@ jero :
|
||||
splitUrl: http://localhost:8080
|
||||
path :
|
||||
#文件上传根目录 设置
|
||||
uploadCos: /upFiles
|
||||
upload: D://opt//upFiles
|
||||
img: D://opt//upFiles/
|
||||
#webapp文件路径
|
||||
|
||||
Reference in New Issue
Block a user