因为项目需要图片需要加密Base64,但是前端JS无法读取JS,所以需要在后台修改成普通的文件流。代码如下
public void startDownFTP1(HttpServletRequest request,
HttpServletResponse response) throws Exception {
FtpConfig list = null;
flag1 = false;
list = ftpConfigServiceI.findObjectByPK(null);
FtpConfigController.connectFtp(list);
String efilename = request.getParameter("efilename");
//2017年3月10日10:19:37 sfb
String imagepath = request.getParameter("imagepath");
String img = FtpConfigController.downloadFile1(list,
efilename, imagepath);// 下载ftp文件测试 ftp /图片名称/文件夹 已通过解密但是有Base64加密
Base64 endcoder=new Base64();
byte [] images;//返回图像
images=endcoder.decodeBase64(img);//Base64转换成byte数组
response.reset();
response.getOutputStream().write(images);
flag1 = true;
FtpConfigController.closeFtp();
}