1.修复不支持文件类型提示时抛异常的问题

2.添加多媒体文件预览支持,如mp4,mp3等文件
This commit is contained in:
chenkailing
2018-03-25 13:26:51 +08:00
parent 378920b773
commit 6f2001b8c9
12 changed files with 97 additions and 22 deletions

View File

@ -0,0 +1,27 @@
package cn.keking.service.impl;
import cn.keking.service.FilePreview;
import cn.keking.utils.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;
/**
* @author : kl
* @authorboke : kailing.pub
* @create : 2018-03-25 上午11:58
* @description:
**/
@Service
public class MediaFilePreviewImpl implements FilePreview {
@Autowired
FileUtils fileUtils;
@Override
public String filePreviewHandle(String url, Model model) {
model.addAttribute("mediaUrl", url);
return "media";
}
}

View File

@ -1,6 +1,9 @@
package cn.keking.service.impl;
import cn.keking.model.FileAttribute;
import cn.keking.service.FilePreview;
import cn.keking.utils.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;
@ -10,8 +13,14 @@ import org.springframework.ui.Model;
*/
@Service
public class OtherFilePreviewImpl implements FilePreview {
@Autowired
FileUtils fileUtils;
@Override
public String filePreviewHandle(String url, Model model) {
FileAttribute fileAttribute=fileUtils.getFileAttribute(url);
model.addAttribute("fileType",fileAttribute.getSuffix());
model.addAttribute("msg", "系统还不支持该格式文件的在线预览," +
"如有需要请按下方显示的邮箱地址联系系统维护人员");
return "fileNotSupported";

View File

@ -30,6 +30,7 @@ public class SimTextFilePreviewImpl implements FilePreview{
ReturnResponse<String> response = simTextUtil.readSimText(decodedUrl, fileName);
if (0 != response.getCode()) {
model.addAttribute("msg", response.getMsg());
model.addAttribute("fileType",fileAttribute.getSuffix());
return "fileNotSupported";
}
model.addAttribute("ordinaryUrl", response.getMsg());