From 0eb477a6ab89e3a927bf0c1027145190f0602675 Mon Sep 17 00:00:00 2001 From: changpengfei Date: Wed, 29 Sep 2021 20:13:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../talkonlineweb/controller/ArticleController.java | 21 +++++++++++++++++++++ .../src/main/resources/application-dev.yml | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/ArticleController.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/ArticleController.java index 25cfecc..89507c8 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/ArticleController.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/ArticleController.java @@ -12,6 +12,7 @@ import com.lyms.talkonlineweb.service.LymsArticleService; import com.lyms.talkonlineweb.service.LymsPushedartService; import com.lyms.talkonlineweb.service.impl.PushedartlogsInfoServiceImpl; import lombok.extern.log4j.Log4j2; +import org.apache.commons.io.IOUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.codec.multipart.Part; @@ -19,7 +20,11 @@ import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.io.OutputStream; import java.util.*; @RestController @@ -74,6 +79,22 @@ public class ArticleController { } /** + * 显示图片 + * @return + */ + @GetMapping("showPic/{fileName}") + public void showPic(@PathVariable("fileName") String fileName, HttpServletResponse response) { + try(InputStream in=new FileInputStream(new File(fileName)); + OutputStream out=response.getOutputStream(); + ){ + IOUtils.copy(in,out); + out.flush(); + }catch (Exception e){ + e.printStackTrace(); + } + } + + /** * 更新或插入文章文章 * * @param article diff --git a/talkonlineweb/src/main/resources/application-dev.yml b/talkonlineweb/src/main/resources/application-dev.yml index 0de462e..747de60 100644 --- a/talkonlineweb/src/main/resources/application-dev.yml +++ b/talkonlineweb/src/main/resources/application-dev.yml @@ -7,7 +7,7 @@ spring: username: platform password: Platform@123 uploadPath: /data/talkonline/upload/ -imgUrlPre: https://dev-talk.healthbaby.com.cn/upload/ +imgUrlPre: https://dev-talk-api.healthbaby.com.cn/showPic/ #环信配置 -- 1.8.3.1