ci: 预览切换到华为云
This commit is contained in:
+45
-44
@@ -156,36 +156,7 @@ public class SysCommonController {
|
||||
response.setContentType("application/force-download");
|
||||
// 然后在您的controller方法中:
|
||||
InputStream watermarkedInputStream = null;
|
||||
if ("pdf".equalsIgnoreCase(FileUtil.extName(fileName))) {
|
||||
try (InputStream originalInputStream = MinioUtil.getMinioFile(MinioUtil.getBucketName(), url);
|
||||
OutputStream outputStream = response.getOutputStream()) {
|
||||
if (originalInputStream == null) {
|
||||
return;
|
||||
}
|
||||
MultipartFile mFile = new MockMultipartFile(fileName, fileName, ContentType.APPLICATION_OCTET_STREAM.toString(), originalInputStream);
|
||||
InputStream inputStream = IntekeyUtils.getInputStreamByDecryptFile(mFile);
|
||||
watermarkedInputStream = sysWaterMarkUtil.addWatermarkToPdf(inputStream);
|
||||
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
while ((len = watermarkedInputStream.read(buf)) > 0) {
|
||||
outputStream.write(buf, 0, len);
|
||||
}
|
||||
response.flushBuffer();
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("error:",e);
|
||||
response.setStatus(404);
|
||||
}finally {
|
||||
try {
|
||||
if (watermarkedInputStream != null){
|
||||
watermarkedInputStream.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else if (CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)) {
|
||||
if (CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)) {
|
||||
try (InputStream inputStream = MinioUtil.getMinioFile(MinioUtil.getBucketName(), url);
|
||||
OutputStream outputStream = response.getOutputStream()
|
||||
) {
|
||||
@@ -204,22 +175,52 @@ public class SysCommonController {
|
||||
}
|
||||
}else if(CommonConstant.UPLOAD_TYPE_OBS.equals(uploadType)) {
|
||||
// 华为云 下载
|
||||
try (InputStream inputStream = ObsBootUtil.getOssFile(fileUrl);
|
||||
OutputStream outputStream = response.getOutputStream()
|
||||
) {
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
while ((len = inputStream.read(buf)) > 0) {
|
||||
outputStream.write(buf, 0, len);
|
||||
if ("pdf".equalsIgnoreCase(FileUtil.extName(fileName))) {
|
||||
try (InputStream originalInputStream = ObsBootUtil.getOssFile(fileUrl);
|
||||
OutputStream outputStream = response.getOutputStream()) {
|
||||
if (originalInputStream == null) {
|
||||
return;
|
||||
}
|
||||
MultipartFile mFile = new MockMultipartFile(fileName, fileName,
|
||||
ContentType.APPLICATION_OCTET_STREAM.toString(), originalInputStream);
|
||||
InputStream inputStream = IntekeyUtils.getInputStreamByDecryptFile(mFile);
|
||||
watermarkedInputStream = sysWaterMarkUtil.addWatermarkToPdf(inputStream);
|
||||
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
while ((len = watermarkedInputStream.read(buf)) > 0) {
|
||||
outputStream.write(buf, 0, len);
|
||||
}
|
||||
response.flushBuffer();
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("error:",e);
|
||||
response.setStatus(404);
|
||||
}finally {
|
||||
try {
|
||||
if (watermarkedInputStream != null){
|
||||
watermarkedInputStream.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try (InputStream inputStream = ObsBootUtil.getOssFile(fileUrl);
|
||||
OutputStream outputStream = response.getOutputStream()
|
||||
) {
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
while ((len = inputStream.read(buf)) > 0) {
|
||||
outputStream.write(buf, 0, len);
|
||||
}
|
||||
response.flushBuffer();
|
||||
} catch (Exception e) {
|
||||
log.error(FILE_VIEW_ERROR + e.getMessage());
|
||||
response.setStatus(404);
|
||||
e.printStackTrace();
|
||||
}
|
||||
response.flushBuffer();
|
||||
} catch (Exception e) {
|
||||
log.error(FILE_VIEW_ERROR + e.getMessage());
|
||||
response.setStatus(404);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user