|
|
@ -14,6 +14,7 @@ import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.ui.Model; |
|
|
|
import org.springframework.ui.Model; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -50,7 +51,7 @@ public class OfficeFilePreviewImpl implements FilePreview { |
|
|
|
String pdfName = fileName.substring(0, fileName.lastIndexOf(".") + 1) + (isHtml ? "html" : "pdf"); |
|
|
|
String pdfName = fileName.substring(0, fileName.lastIndexOf(".") + 1) + (isHtml ? "html" : "pdf"); |
|
|
|
String cacheFileName = userToken == null ? pdfName : userToken + "_" + pdfName; |
|
|
|
String cacheFileName = userToken == null ? pdfName : userToken + "_" + pdfName; |
|
|
|
String outFilePath = FILE_DIR + cacheFileName; |
|
|
|
String outFilePath = FILE_DIR + cacheFileName; |
|
|
|
|
|
|
|
if ( !fileHandlerService.listConvertedFiles().containsKey(pdfName) || !ConfigConstants.isCacheEnabled()) { |
|
|
|
// 下载远程文件到本地,如果文件在本地已存在不会重复下载
|
|
|
|
// 下载远程文件到本地,如果文件在本地已存在不会重复下载
|
|
|
|
ReturnResponse<String> response = DownloadUtils.downLoad(fileAttribute, fileName); |
|
|
|
ReturnResponse<String> response = DownloadUtils.downLoad(fileAttribute, fileName); |
|
|
|
if (response.isFailure()) { |
|
|
|
if (response.isFailure()) { |
|
|
@ -115,11 +116,11 @@ public class OfficeFilePreviewImpl implements FilePreview { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
if (!isHtml && baseUrl != null && (OFFICE_PREVIEW_TYPE_IMAGE.equals(officePreviewType) || OFFICE_PREVIEW_TYPE_ALL_IMAGES.equals(officePreviewType))) { |
|
|
|
if (!isHtml && baseUrl != null && (OFFICE_PREVIEW_TYPE_IMAGE.equals(officePreviewType) || OFFICE_PREVIEW_TYPE_ALL_IMAGES.equals(officePreviewType))) { |
|
|
|
return getPreviewType(model, fileAttribute, officePreviewType, baseUrl, cacheFileName, outFilePath, fileHandlerService, OFFICE_PREVIEW_TYPE_IMAGE, otherFilePreview); |
|
|
|
return getPreviewType(model, fileAttribute, officePreviewType, baseUrl, cacheFileName, outFilePath, fileHandlerService, OFFICE_PREVIEW_TYPE_IMAGE, otherFilePreview); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
cacheFileName = URLEncoder.encode(cacheFileName).replaceAll("\\+", "%20"); |
|
|
|
model.addAttribute("pdfUrl", cacheFileName); |
|
|
|
model.addAttribute("pdfUrl", cacheFileName); |
|
|
|
return isHtml ? EXEL_FILE_PREVIEW_PAGE : PDF_FILE_PREVIEW_PAGE; |
|
|
|
return isHtml ? EXEL_FILE_PREVIEW_PAGE : PDF_FILE_PREVIEW_PAGE; |
|
|
|
} |
|
|
|
} |
|
|
|