fix: 金蝶PDF版式文件响应强制application/pdf,修复查看时blob不渲染退化为静默下载
This commit is contained in:
+4
@@ -1301,6 +1301,10 @@ public class InvoiceReceiptServiceImpl extends BaseServiceImpl<InvoiceReceiptMap
|
||||
throw new ServiceException("调用BFI文件下载失败:" + readBfiJsonMessage(bfiResponse));
|
||||
}
|
||||
String fileName = Func.isBlank(item.name()) ? invoiceNo + ".pdf" : item.name();
|
||||
// BFI 文件流统一回 octet-stream:PDF 版式须显式声明 MIME,否则浏览器 blob 不渲染、查看退化为静默下载
|
||||
if (fileName.endsWith(".pdf") && (Func.isBlank(contentType) || contentType.contains("octet-stream"))) {
|
||||
contentType = "application/pdf";
|
||||
}
|
||||
// 文件名按 RFC 5987 编码(+ 号转 %20),中文/特殊字符不乱码
|
||||
String encodedName = URLEncoder.encode(fileName, StandardCharsets.UTF_8).replace("+", "%20");
|
||||
response.setContentType(Func.isBlank(contentType) ? "application/pdf" : contentType);
|
||||
|
||||
Reference in New Issue
Block a user