SFTPUtils sftp = new SFTPUtils("XXX", "XXX", "XXX", XX);
sftp.login();
if(uuidList.size()>0){//增加prpclaimphotoinfo表uuid集合上床图片
for(int i=0;i<uuidList.size();i++){
Prpclaimphotoinfo prpgyregistimageinfo=prpclaimphotoinfoMapper.selectByPrimaryKey(uuidList.get(i));
//得到sftp文件名
String pathname = prpgyregistimageinfo.getClaimImage();
String imageBase64 = (sftp.downloadClaim("/home/zyeb/claim",pathname));
//imageBase64 = imageBase64.replace("\r", "").replace("\n", "");
//imageBase64 = imageBase64.replace(imageBase64.substring(0, imageBase64.indexOf(",")+1), "");
//LOGGER.info("imageBase64:{}",imageBase64);
BASE64Decoder decode = new BASE64Decoder();
b.add(decode.decodeBuffer(imageBase64)) ;
//生成jpg图片
String photoName=UUID.randomUUID().toString();
photoNameList.add(photoName+".jpg");
filePath = filePath+"\"+photoName+".jpg";//新生成的图片
OutputStream out = new FileOutputStream(filePath);
System.out.println(filePath);
out.write(decode.decodeBuffer(imageBase64));
out.flush();
out.close();
}
sftp.logout();
报错内容为:
[DEBUG]:2019-06-13 20:41:58,181 -- com.zyeb.framework.web.controller.JsonExceptionResolver -- Resolving exception from handler [public com.zyeb.utils.dto.ResponseDto com.claim.app.controller.AppMobileSurveyController.imageUpload(com.claim.mobilesurvey.dto.ClaimServiceReqDto,javax.servlet.http.HttpServletRequest) throws java.lang.Exception]: java.io.FileNotFoundException: C:\Users\zichu\AppData\Local\Temp\a8f5dbca-a22a-4153-b5aa-ee04306c4cc6.jpg\f824d802-b0bd-4f67-b21a-c6ba48bf8aee.jpg (系统找不到指定的路径。)
[ERROR]:2019-06-13 20:41:58,181 -- com.zyeb.framework.web.controller.JsonExceptionResolver -- 未知异常
java.io.FileNotFoundException: C:\Users\zichu\AppData\Local\Temp\a8f5dbca-a22a-4153-b5aa-ee04306c4cc6.jpg\f824d802-b0bd-4f67-b21a-c6ba48bf8aee.jpg (系统找不到指定的路径。)
仔细看错误提示,路径拼接错了。
C:\Users\zichu\AppData\Local\Temp\a8f5dbca-a22a-4153-b5aa-ee04306c4cc6.jpg\f824d802-b0bd-4f67-b21a-c6ba48bf8aee.jpg
这里面有两个.jpg,你把多张图的路径拼在一起了,实际上多张图的时候,路径应该是多个,然后一个一个保存
如:
C:\Users\zichu\AppData\Local\Temp\a8f5dbca-a22a-4153-b5aa-ee04306c4cc6.jpg
C:\Users\zichu\AppData\Local\Temp\f824d802-b0bd-4f67-b21a-c6ba48bf8aee.jpg
解决...一直认为我的路径没毛病 实际上真是路径问题 ,谢谢