去除asopse,使用第三方实现;弱口令升级;待审核数量提示
This commit is contained in:
parent
1ad8dec41e
commit
2fd7323d79
|
@ -1,20 +0,0 @@
|
||||||
package org.dromara.system.service;
|
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public interface IFileService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 预览文件
|
|
||||||
*
|
|
||||||
* @param ossId
|
|
||||||
* @param response
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
void preview(Long ossId, HttpServletResponse response) throws Exception;
|
|
||||||
|
|
||||||
void download(Long id, HttpServletResponse response);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,89 +0,0 @@
|
||||||
package org.dromara.system.service.impl;
|
|
||||||
|
|
||||||
import com.aspose.cells.Workbook;
|
|
||||||
import com.aspose.slides.Presentation;
|
|
||||||
import com.aspose.words.Document;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.dromara.common.oss.core.OssClient;
|
|
||||||
import org.dromara.common.oss.factory.OssFactory;
|
|
||||||
import org.dromara.system.domain.vo.SysOssVo;
|
|
||||||
import org.dromara.system.service.IFileService;
|
|
||||||
import org.dromara.system.service.ISysOssService;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>TODO<p>
|
|
||||||
*
|
|
||||||
* @author cjw
|
|
||||||
* @version V1.0.0
|
|
||||||
* @date 2024/5/31 14:39
|
|
||||||
*/
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@Service
|
|
||||||
public class FileService implements IFileService {
|
|
||||||
|
|
||||||
private final ISysOssService ossService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 预览文件
|
|
||||||
*
|
|
||||||
* @param ossId
|
|
||||||
* @param response
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void preview(Long ossId, HttpServletResponse response) throws Exception {
|
|
||||||
SysOssVo sysOss = ossService.getById(ossId);
|
|
||||||
OssClient storage = OssFactory.instance(sysOss.getService());
|
|
||||||
InputStream is = null;
|
|
||||||
OutputStream os = null;
|
|
||||||
try {
|
|
||||||
is = storage.getObjectContent(sysOss.getFileName());
|
|
||||||
os = response.getOutputStream();
|
|
||||||
byte[] byteData = new byte[1024];
|
|
||||||
// 前端word预览仅支持.docx,将.doc转换为.docx
|
|
||||||
if ((".doc").equals(sysOss.getFileSuffix())) {
|
|
||||||
Document doc = new Document(is);
|
|
||||||
doc.save(os, com.aspose.words.SaveFormat.DOCX);
|
|
||||||
}
|
|
||||||
if ((".xls").equals(sysOss.getFileSuffix())) {
|
|
||||||
Workbook xls = new Workbook(is);
|
|
||||||
xls.save(os, com.aspose.cells.SaveFormat.XLSX);
|
|
||||||
}
|
|
||||||
if ((".ppt").equals(sysOss.getFileSuffix())) {
|
|
||||||
Presentation xls = new Presentation(is);
|
|
||||||
xls.save(os, com.aspose.slides.SaveFormat.Pptx);
|
|
||||||
}
|
|
||||||
int len = 0;
|
|
||||||
while ((len = is.read(byteData)) != -1) {
|
|
||||||
os.write(byteData, 0, len);
|
|
||||||
}
|
|
||||||
os.flush();
|
|
||||||
} finally {
|
|
||||||
if (os != null) {
|
|
||||||
try {
|
|
||||||
os.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
//log.error("IO异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (is != null) {
|
|
||||||
try {
|
|
||||||
is.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
//log.error("IO异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void download(Long id, HttpServletResponse response) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue