返回文件输出流

This commit is contained in:
zhangyx
2021-03-25 15:53:22 +08:00
parent 8ab8112829
commit 56486f2c2e
3 changed files with 36 additions and 0 deletions

View File

@ -79,6 +79,20 @@ public class TemplateWarehouseController {
return BaseResponse.success(clientVersion);
}
/**
* 获得客户端配置文件相关信息
*
* @return
*/
@ApiOperation("获得客户端配置文件文件id")
@GetMapping("/client/filess")
public BaseResponse<FileOutputStream> getClientFiless() throws IOException {
String type = "ipassConfigFile";
BizBidTemplateWarehouse templateWarehouse = templateWarehouseService.getTemplateByType(type);
FileOutputStream clientVersion = bizBidClientVersionService.downloadFileByObjectIdss(templateWarehouse.getDocumentCenterId());
return BaseResponse.success(clientVersion);
}
/**
* 通过版本号获得对应客户端文件id
*

View File

@ -24,4 +24,6 @@ public interface BizBidClientVersionService extends IBaseService<BizBidClientVer
FileOutputStream downloadFileByObjectId(String oId) throws IOException;
FileOutputStream downloadFileByObjectIds(String oId) throws IOException;
FileOutputStream downloadFileByObjectIdss(String oId) throws IOException;
}

View File

@ -77,4 +77,24 @@ public class BizBidClientVersionServiceImpl extends BaseServiceImpl<BizBidClient
}
return fileOutputStream;
}
@Override
public FileOutputStream downloadFileByObjectIdss(String objectId) throws IOException {
log.info("文档中心s文件下载传入数据"+ JsonUtils.objectToJson(objectId));
String objectInfo = documentCenterService.getObjectDetail(objectId);
log.info("文档中心s文件下载返回数据"+ JsonUtils.objectToJson(objectInfo));
Optional<byte[]> optionalBytes = modelConvertor.toByteArray(objectInfo);
log.info("文档中心s文件下载返回数据转为byte[]数据:"+ JsonUtils.objectToJson(optionalBytes));
FileOutputStream fileOutputStream = null;
if(optionalBytes.isPresent()){
ByteArrayOutputStream fileStream = new ByteArrayOutputStream();
fileStream.write(optionalBytes.get());
log.info("文档中心s文件下载返回数据转为ByteArrayOutputStream数据"+ JsonUtils.objectToJson(fileStream));
fileOutputStream = new FileOutputStream("C:\\test.txt");
fileOutputStream.write(fileStream.toByteArray());
log.info("文档中心s文件下载返回数据转为ByteArrayOutputStream数据"+ JsonUtils.objectToJson(fileOutputStream));
}
return fileOutputStream;
}
}