支持http/https文件流作为预览源url

This commit is contained in:
陈精华
2019-06-17 14:21:16 +08:00
committed by kl
parent cf1ee9c631
commit fb7cdfbef7
14 changed files with 114 additions and 44 deletions

View File

@ -28,8 +28,7 @@ public class CompressFilePreviewImpl implements FilePreview{
ZipReader zipReader;
@Override
public String filePreviewHandle(String url, Model model) {
FileAttribute fileAttribute=fileUtils.getFileAttribute(url);
public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) {
String fileName=fileAttribute.getName();
String decodedUrl=fileAttribute.getDecodedUrl();
String suffix=fileAttribute.getSuffix();

View File

@ -19,9 +19,8 @@ public class MediaFilePreviewImpl implements FilePreview {
FileUtils fileUtils;
@Override
public String filePreviewHandle(String url, Model model) {
public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) {
model.addAttribute("mediaUrl", url);
FileAttribute fileAttribute=fileUtils.getFileAttribute(url);
String suffix=fileAttribute.getSuffix();
if ("flv".equalsIgnoreCase(suffix)) {
return "flv";

View File

@ -9,9 +9,7 @@ import cn.keking.utils.FileUtils;
import cn.keking.utils.OfficeToPdf;
import cn.keking.utils.PdfUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.ui.ExtendedModelMap;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
@ -44,11 +42,10 @@ public class OfficeFilePreviewImpl implements FilePreview {
public static final String OFFICE_PREVIEW_TYPE_ALLIMAGES = "allImages";
@Override
public String filePreviewHandle(String url, Model model) {
public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) {
// 预览Type参数传了就取参数的没传取系统默认
String officePreviewType = model.asMap().get("officePreviewType") == null ? ConfigConstants.getOfficePreviewType() : model.asMap().get("officePreviewType").toString();
String originUrl = (String) model.asMap().get("originUrl");
FileAttribute fileAttribute=fileUtils.getFileAttribute(url);
String suffix=fileAttribute.getSuffix();
String fileName=fileAttribute.getName();
String decodedUrl=fileAttribute.getDecodedUrl();

View File

@ -17,9 +17,7 @@ public class OtherFilePreviewImpl implements FilePreview {
FileUtils fileUtils;
@Override
public String filePreviewHandle(String url, Model model) {
FileAttribute fileAttribute=fileUtils.getFileAttribute(url);
public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) {
model.addAttribute("fileType",fileAttribute.getSuffix());
model.addAttribute("msg", "系统还不支持该格式文件的在线预览," +
"如有需要请按下方显示的邮箱地址联系系统维护人员");

View File

@ -34,8 +34,7 @@ public class PdfFilePreviewImpl implements FilePreview{
String fileDir = ConfigConstants.getFileDir();
@Override
public String filePreviewHandle(String url, Model model) {
FileAttribute fileAttribute=fileUtils.getFileAttribute(url);
public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) {
String decodedUrl=fileAttribute.getDecodedUrl();
String suffix=fileAttribute.getSuffix();
String fileName=fileAttribute.getName();

View File

@ -1,5 +1,6 @@
package cn.keking.service.impl;
import cn.keking.model.FileAttribute;
import cn.keking.service.FilePreview;
import cn.keking.utils.FileUtils;
import com.google.common.collect.Lists;
@ -21,7 +22,7 @@ public class PictureFilePreviewImpl implements FilePreview {
FileUtils fileUtils;
@Override
public String filePreviewHandle(String url, Model model) {
public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) {
String fileKey=(String) RequestContextHolder.currentRequestAttributes().getAttribute("fileKey",0);
List imgUrls = Lists.newArrayList(url);
try{

View File

@ -23,8 +23,7 @@ public class SimTextFilePreviewImpl implements FilePreview{
FileUtils fileUtils;
@Override
public String filePreviewHandle(String url, Model model){
FileAttribute fileAttribute=fileUtils.getFileAttribute(url);
public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute){
String decodedUrl=fileAttribute.getDecodedUrl();
String fileName=fileAttribute.getName();
ReturnResponse<String> response = simTextUtil.readSimText(decodedUrl, fileName);