在线编辑对接-查看历史文件接口。
This commit is contained in:
+48
@@ -14,15 +14,18 @@ import com.jero.modules.onlyoffice.entity.BusProcessModelHis;
|
|||||||
import com.jero.modules.onlyoffice.entity.OnlineFileLog;
|
import com.jero.modules.onlyoffice.entity.OnlineFileLog;
|
||||||
import com.jero.modules.onlyoffice.mapper.BusProcessModelHisMapper;
|
import com.jero.modules.onlyoffice.mapper.BusProcessModelHisMapper;
|
||||||
import com.jero.modules.onlyoffice.mapper.OnlineFileLogDao;
|
import com.jero.modules.onlyoffice.mapper.OnlineFileLogDao;
|
||||||
|
import com.jero.modules.onlyoffice.service.IAttFileEOService;
|
||||||
import com.jero.modules.onlyoffice.service.IBusProcessModelHisService;
|
import com.jero.modules.onlyoffice.service.IBusProcessModelHisService;
|
||||||
import com.jero.modules.onlyoffice.service.LawsUserInfoService;
|
import com.jero.modules.onlyoffice.service.LawsUserInfoService;
|
||||||
import com.jero.modules.oss.entity.OSSFile;
|
import com.jero.modules.oss.entity.OSSFile;
|
||||||
import com.jero.modules.oss.service.IOSSFileService;
|
import com.jero.modules.oss.service.IOSSFileService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
@@ -34,6 +37,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -66,6 +70,12 @@ public class OnlyOfficeController {
|
|||||||
@Resource
|
@Resource
|
||||||
private OnlineFileLogDao onlineFileLogDao;
|
private OnlineFileLogDao onlineFileLogDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IAttFileEOService attFileEOService;
|
||||||
|
|
||||||
|
@Value("${file.path}")
|
||||||
|
private String filePath;//文件存储路径
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件后缀黑名单
|
* 文件后缀黑名单
|
||||||
*/
|
*/
|
||||||
@@ -435,5 +445,43 @@ public class OnlyOfficeController {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation(value = "|File|在线编辑防止加密的接口下载文件")
|
||||||
|
@GetMapping("/downloadFileForSarNewOnlyOffice")
|
||||||
|
public void downloadFileForSarNewOnlyOffice(String fileId, HttpServletResponse response, HttpServletRequest request) throws Exception {
|
||||||
|
OSSFile ossFile = ossFileService.getById(fileId);
|
||||||
|
|
||||||
|
InputStream is = null;
|
||||||
|
OutputStream os = null;
|
||||||
|
response.reset();
|
||||||
|
try {
|
||||||
|
String fileOldName = fileNameEncoding(ossFile.getFileName(), request);
|
||||||
|
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||||
|
response.setHeader("Content-Disposition", "attachment;filename=\"" + fileOldName + "\"");
|
||||||
|
response.setContentType("application/octet-stream");
|
||||||
|
File file = new File(filePath + ossFile.getUrl() + ossFile.getFileName());
|
||||||
|
is = new FileInputStream(file);
|
||||||
|
os = response.getOutputStream();
|
||||||
|
IOUtils.copy(is, os);
|
||||||
|
os.flush();
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
} finally {
|
||||||
|
IOUtils.closeQuietly(is);
|
||||||
|
IOUtils.closeQuietly(os);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String fileNameEncoding(String fileName, HttpServletRequest request) throws IOException {
|
||||||
|
String agent = request.getHeader("User-Agent");
|
||||||
|
if (agent.contains("Firefox")) {
|
||||||
|
fileName = new String(fileName.getBytes("UTF-8"), "ISO8859-1"); // firefox浏览器
|
||||||
|
} else {
|
||||||
|
fileName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");
|
||||||
|
//谷歌中空格变为+问题
|
||||||
|
fileName = fileName.replaceAll("\\+","%20");
|
||||||
|
}
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user