@Override
public TClaimImageVo downloadToPath(String path, String fileInfoId) {
ResponseEntity<FileInfoVO> responseEntity=remoteOssService.downloadFileInfo(channelKey,fileInfoId);
String fileName=responseEntity.getBody().getFileName();
byte[] imgArr= responseEntity.getBody().getBuffer();
File fileDir=new File(path);
fileDir.setWritable(true, false);
try {
if (!fileDir.exists()) {
fileDir.mkdirs();
}
FileOutputStream downloadFile = new FileOutputStream(path+ "/" + fileName);
downloadFile.write(imgArr);
downloadFile.flush();
downloadFile.close();
TClaimImageVo tClaimImageVo=new TClaimImageVo();
tClaimImageVo.setFullFileName(path+ "/" + fileName);
tClaimImageVo.setFileName(fileName);
return tClaimImageVo;
}catch (Exception ex){
logger.info("downlaodImageFile: "+ex.getMessage());
return null;
}
}
ResponseEntity<FileInfoVO> responseEntity=remoteOssService.downloadFileInfo(channelKey,fileInfoId);
String fileName=responseEntity.getBody().getFileName();
byte[] imgArr= responseEntity.getBody().getBuffer();;
File fileDir=new File(path);
fileDir.setWritable(true, false);
FileWriter fileWriter=null;
try {
if (fileDir.exists()) {
FileOutputStream downloadFile = new FileOutputStream(path+ "/" + fileName);
downloadFile.write(imgArr);
downloadFile.flush();
downloadFile.close();
// File file = new File(path + "/" + fileName);
// file.setWritable(true, false);
// if (file.exists()) {
// // 向文件写入对象写入信息
// fileWriter = new FileWriter(file, true);
// } else {
// fileWriter = new FileWriter(file);
// }
} else {
fileDir.mkdirs();
FileOutputStream downloadFile = new FileOutputStream(path+ "/" + fileName);
downloadFile.write(imgArr);
downloadFile.flush();
downloadFile.close();
// File file = new File(path + "/" + fileName);
// file.setWritable(true, false);
// fileWriter = new FileWriter(file);
}
// 写文件
// fileWriter.write(new String(imgArr));
// 关闭
//fileWriter.close();
}catch (Exception ex){
logger.info("downlaodImageFile: "+ex.getMessage());
}