111
wang-hao-jie
2022-08-25 d90da0759bd93c7f429f6a20bc835782ad927c02
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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) {
 
        }
    }
 
}