package com.boying.common;
|
|
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.IOUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.http.MediaType;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import javax.servlet.ServletOutputStream;
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
import java.io.File;
|
import java.io.IOException;
|
import java.io.InputStream;
|
|
@RestController
|
@RequestMapping("show")
|
public class ShowImgController extends BaseController {
|
|
@Autowired
|
private SystemConfigProperties systemConfigProperties;
|
|
//资料地址回显
|
@RequestMapping(value = "/showImg", method = RequestMethod.GET)
|
public void getAwardAsByteArray(HttpServletResponse response, HttpServletRequest request) throws IOException {
|
String result = request.getParameter("result");
|
InputStream in = null;
|
in = FileUtils.openInputStream(new File(systemConfigProperties.getUploadImgPath()+result));
|
response.setContentType(String.valueOf(MediaType.ALL));
|
ServletOutputStream out = response.getOutputStream();
|
try {
|
IOUtils.copy(in, out);
|
out.close();
|
in.close();
|
} catch (IOException e) {
|
|
}
|
}
|
|
//头像图片回显
|
@RequestMapping(value = "/showImg2", method = RequestMethod.GET)
|
public void getAwardAsByteArray2(HttpServletResponse response, HttpServletRequest request) throws IOException {
|
String result = request.getParameter("result");
|
InputStream in = null;
|
in = FileUtils.openInputStream(new File(systemConfigProperties.getUploadImgPath2()+result));
|
response.setContentType(String.valueOf(MediaType.ALL));
|
ServletOutputStream out = response.getOutputStream();
|
try {
|
IOUtils.copy(in, out);
|
out.close();
|
in.close();
|
} catch (IOException e) {
|
|
}
|
}
|
|
//头像图片回显
|
@RequestMapping(value = "/showImg3", method = RequestMethod.GET)
|
public void getAwardAsByteArray3(HttpServletResponse response, HttpServletRequest request) throws IOException {
|
String result = request.getParameter("result");
|
InputStream in = null;
|
in = FileUtils.openInputStream(new File(systemConfigProperties.getUploadUserPath()+result));
|
response.setContentType(String.valueOf(MediaType.ALL));
|
ServletOutputStream out = response.getOutputStream();
|
try {
|
IOUtils.copy(in, out);
|
out.close();
|
in.close();
|
} catch (IOException e) {
|
|
}
|
}
|
|
}
|