Merge branch 'dev' into 'master'

返回流加Content-Length

See merge request eshop/biz_service_ebtp_extend!26
This commit is contained in:
张银雪
2021-04-08 09:40:28 +08:00

View File

@ -60,11 +60,15 @@ public class BizBidClientVersionServiceImpl extends BaseServiceImpl<BizBidClient
ExportExceptionEnum.FRAME_EXCEPTION_GET_DOCUMENT_CENTER.customValidName("文档获取失败", !(map.containsKey("message") && map.containsKey("success")) || "null".equals(objectInfo));
ExportExceptionEnum.FRAME_EXCEPTION_GET_DOCUMENT_CENTER.customValidName("文档中心返回信息:" + map.get("message").toString(), !(boolean) map.get("success"));
Optional<byte[]> optionalBytes = modelConvertor.toByteArray(objectInfo);
// log.info("文档中心文件下载返回数据转为byte[]数据:"+ new String(optionalBytes.get()));
String data = map.get("data").toString();
Map mapdata = (Map) JSON.parse(data);
String sysStorageVO = mapdata.get("sysStorageVO").toString();
Map mapsysStorageVO = (Map) JSON.parse(sysStorageVO);
log.info("文档中心文件下载返回文件大小数据:"+ mapsysStorageVO.get("fileSize"));
ServletOutputStream outputStream = response.getOutputStream();
// response.setContentType("application/octet-stream;charset=utf-8");
response.setHeader("Content-Disposition","attachment;filename="+ URLEncoder.encode("AutoUpdater.xml", "utf-8"));
if(optionalBytes.isPresent()){
response.setHeader("Content-Length",mapsysStorageVO.get("fileSize").toString());
outputStream.write(optionalBytes.get());
}
outputStream.flush();
@ -79,11 +83,15 @@ public class BizBidClientVersionServiceImpl extends BaseServiceImpl<BizBidClient
ExportExceptionEnum.FRAME_EXCEPTION_GET_DOCUMENT_CENTER.customValidName("文档获取失败", !(map.containsKey("message") && map.containsKey("success")) || "null".equals(objectInfo));
ExportExceptionEnum.FRAME_EXCEPTION_GET_DOCUMENT_CENTER.customValidName("文档中心返回信息:" + map.get("message").toString(), !(boolean) map.get("success"));
Optional<byte[]> optionalBytes = modelConvertor.toByteArray(objectInfo);
// log.info("文档中心s文件下载返回数据转为byte[]数据:"+ optionalBytes.get());
String data = map.get("data").toString();
Map mapdata = (Map) JSON.parse(data);
String sysStorageVO = mapdata.get("sysStorageVO").toString();
Map mapsysStorageVO = (Map) JSON.parse(sysStorageVO);
log.info("文档中心s文件下载返回文件大小数据"+ mapsysStorageVO.get("fileSize"));
ServletOutputStream outputStream = response.getOutputStream();
// response.setContentType("application/octet-stream;charset=utf-8");
response.setHeader("Content-Disposition","attachment;filename="+ URLEncoder.encode("ebtp-ca.zip", "utf-8"));
if(optionalBytes.isPresent()){
response.setHeader("Content-Length",mapsysStorageVO.get("fileSize").toString());
outputStream.write(optionalBytes.get());
}
outputStream.flush();