Commit 52c84058 by 黄森林

二维码bug修复

parent bf89d887
......@@ -2,6 +2,7 @@ package com.winsun.utils;
import com.winsun.constant.FilePath;
import lombok.extern.slf4j.Slf4j;
import sun.misc.BASE64Decoder;
import java.io.FileOutputStream;
import java.io.IOException;
......@@ -25,7 +26,7 @@ public class PicturesUtil {
* @param path 图片文件夹名
* @return
*/
public static String uploadPictures(String file, String path) {
public static String uploadPictures(String file, String path){
Date date = new Date();
SimpleDateFormat yyMM = new SimpleDateFormat("yyMM");
String y = yyMM.format(date.getTime());
......@@ -40,11 +41,13 @@ public class PicturesUtil {
/**
* 2.解码成字节数组
*/
filePath = FilePath.IDCARD.getValue() + y + "/" + h + "/" + path + "/" + date.getTime() + "." + houzhui;
Base64.Decoder decoder = Base64.getDecoder();
byte[] bytes = decoder.decode(base64Data);
FileOutputStream fos = null;
//filePath = "C:\\Users\\asus\\Desktop\\新建文件夹\\" + date.getTime()+ "." + houzhui;
//byte[] bytes = Base64.getUrlDecoder().decode(base64Data);
//byte[] bytes =new BASE64Decoder().decodeBuffer(base64Data);
//byte[] bytes = Base64.getDecoder().decode(base64Data);
byte[] bytes = Base64.getMimeDecoder().decode(base64Data.replace(" ","+"));
FileOutputStream fos = null;
try {
fos = new FileOutputStream(filePath);
fos.write(bytes);
......
......@@ -19,6 +19,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.*;
......@@ -40,7 +41,7 @@ public class QRCodeController extends BaseController {
}
@Permission(menuname = "二维码上传图片",value = "picture", method = RequestMethod.POST)
public ResponseData<String> uploadPicture(@RequestParam("picture") String picture){
public ResponseData<String> uploadPicture(@RequestParam("picture") String picture) {
ShiroUser user = getShiroUser();
Integer userId=user.getId();
String path = PicturesUtil.uploadPictures(picture, userId.toString());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment