ecology_maven/com/api/aiyh_kafang/service/UploadByBase64Service.java

33 lines
864 B
Java
Raw Normal View History

2021-11-14 15:29:16 +08:00
package com.api.aiyh_kafang.service;
import aiyh.utils.zwl.common.ToolUtil;
import org.apache.axiom.util.base64.Base64Utils;
import weaver.file.ImageFileManager;
import java.util.Map;
import java.util.UUID;
/**
* @author EBU7-dev1-ayh
* @create 2021/10/8 0008 13:36
*
*/
public class UploadByBase64Service {
public int uploadImage(Map<String, String> param) {
ToolUtil toolUtil = new ToolUtil();
String base64 = String.valueOf(param.get("base64"));
ImageFileManager fileManager = new ImageFileManager();
byte[] data = null;
data = Base64Utils.decode(base64);
fileManager.setData(data);
String fileName = "" + System.currentTimeMillis() + UUID.randomUUID() + ".jpg";
fileManager.setImagFileName(fileName);
int i = fileManager.saveImageFile();
toolUtil.writeErrorLog("生成的图片的id" + i);
return i;
}
}