From bc3242a52a9bb57dd52c2bc6a1bcb3368b5643ef Mon Sep 17 00:00:00 2001 From: liquanyu Date: Wed, 23 May 2018 17:46:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=99=BA=E8=83=BD=E5=BB=BA=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/lyms/platform/common/utils/FileUtil.java | 41 ++++++++++++++++++++++ .../web/controller/PregnantBuildController.java | 30 ++++++++-------- .../operate/web/facade/BookbuildingFacade.java | 35 ++++++++++++++++++ .../platform/operate/web/request/ImgRequest.java | 17 +++++++++ 4 files changed, 109 insertions(+), 14 deletions(-) create mode 100644 platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/ImgRequest.java diff --git a/platform-common/src/main/java/com/lyms/platform/common/utils/FileUtil.java b/platform-common/src/main/java/com/lyms/platform/common/utils/FileUtil.java index 6853b38..564a768 100644 --- a/platform-common/src/main/java/com/lyms/platform/common/utils/FileUtil.java +++ b/platform-common/src/main/java/com/lyms/platform/common/utils/FileUtil.java @@ -1,9 +1,12 @@ package com.lyms.platform.common.utils; import org.apache.commons.io.FileUtils; +import sun.misc.BASE64Decoder; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStream; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -44,6 +47,44 @@ public class FileUtil { return false; } + + //base64字符串转化成图片 + public static boolean generateImage(String imgStr,String imgFilePath) + { //对字节数组字符串进行Base64解码并生成图片 + if (imgStr == null) //图像数据为空 + return false; + BASE64Decoder decoder = new BASE64Decoder(); + OutputStream out = null; + try + { + //Base64解码 + byte[] b = decoder.decodeBuffer(imgStr); + for(int i=0;i