Commit 0eb477a6ab89e3a927bf0c1027145190f0602675
1 parent
c5b07c9d79
Exists in
master
and in
1 other branch
图片显示
Showing 2 changed files with 22 additions and 1 deletions
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/ArticleController.java
View file @
0eb477a
| ... | ... | @@ -12,6 +12,7 @@ |
| 12 | 12 | import com.lyms.talkonlineweb.service.LymsPushedartService; |
| 13 | 13 | import com.lyms.talkonlineweb.service.impl.PushedartlogsInfoServiceImpl; |
| 14 | 14 | import lombok.extern.log4j.Log4j2; |
| 15 | +import org.apache.commons.io.IOUtils; | |
| 15 | 16 | import org.springframework.beans.factory.annotation.Autowired; |
| 16 | 17 | import org.springframework.beans.factory.annotation.Value; |
| 17 | 18 | import org.springframework.http.codec.multipart.Part; |
| 18 | 19 | |
| ... | ... | @@ -19,7 +20,11 @@ |
| 19 | 20 | import org.springframework.web.bind.annotation.*; |
| 20 | 21 | import org.springframework.web.multipart.MultipartFile; |
| 21 | 22 | |
| 23 | +import javax.servlet.http.HttpServletResponse; | |
| 22 | 24 | import java.io.File; |
| 25 | +import java.io.FileInputStream; | |
| 26 | +import java.io.InputStream; | |
| 27 | +import java.io.OutputStream; | |
| 23 | 28 | import java.util.*; |
| 24 | 29 | |
| 25 | 30 | @RestController |
| ... | ... | @@ -71,6 +76,22 @@ |
| 71 | 76 | } |
| 72 | 77 | |
| 73 | 78 | return furl; |
| 79 | + } | |
| 80 | + | |
| 81 | + /** | |
| 82 | + * 显示图片 | |
| 83 | + * @return | |
| 84 | + */ | |
| 85 | + @GetMapping("showPic/{fileName}") | |
| 86 | + public void showPic(@PathVariable("fileName") String fileName, HttpServletResponse response) { | |
| 87 | + try(InputStream in=new FileInputStream(new File(fileName)); | |
| 88 | + OutputStream out=response.getOutputStream(); | |
| 89 | + ){ | |
| 90 | + IOUtils.copy(in,out); | |
| 91 | + out.flush(); | |
| 92 | + }catch (Exception e){ | |
| 93 | + e.printStackTrace(); | |
| 94 | + } | |
| 74 | 95 | } |
| 75 | 96 | |
| 76 | 97 | /** |
talkonlineweb/src/main/resources/application-dev.yml
View file @
0eb477a