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

33 lines
864 B
Java
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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;
}
}