From 9ac5bfa31100c9d1bed920410b57fa045177068d Mon Sep 17 00:00:00 2001 From: xd <844539747@qq.com> Date: Tue, 9 Jul 2024 15:06:25 +0800 Subject: [PATCH] '1223' --- .../com/ruoyi/common/utils/sign/Base64.java | 24 +++++++++++++++++++ .../main/resources/mapper/quot/QuotMapper.xml | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/sign/Base64.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/sign/Base64.java index 9eddf2a..bf9868b 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/sign/Base64.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/sign/Base64.java @@ -6,7 +6,10 @@ import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; +import sun.misc.BASE64Decoder; +import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -296,6 +299,27 @@ public final class Base64 return encode; } + /** + * 将base64字符串转为文件 + * @param base64 + * @param filePath + * @return + */ + public File base64File(String base64, String filePath) { + File file = new File(filePath); + byte[] buffer; + try { + BASE64Decoder base64Decoder = new BASE64Decoder(); + buffer = base64Decoder.decodeBuffer(base64); + FileOutputStream out = new FileOutputStream(filePath); + out.write(buffer); + out.close(); + } catch (Exception e) { + return null; + } + return file; + } + /** * remove WhiteSpace from MIME containing encoded Base64 data. * diff --git a/ruoyi-system/src/main/resources/mapper/quot/QuotMapper.xml b/ruoyi-system/src/main/resources/mapper/quot/QuotMapper.xml index a69c6f5..1dea577 100644 --- a/ruoyi-system/src/main/resources/mapper/quot/QuotMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/quot/QuotMapper.xml @@ -557,7 +557,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"