依赖包
import sun.misc.BASE64Decoder;
import java.io.FileOutputStream;
import java.io.OutputStream;
代码:
@PostMapping(value = "/uploadImageBase64")
public Result uploadFileBase64(@RequestBody String base64Str) throws Exception {
# 省略部分
# 要先转码? encode下
String base64Data = imgStr.split(",")[1];
BASE64Decoder decoder = new BASE64Decoder();
byte[] bytes = decoder.decodeBuffer(base64Data);
InputStream inputStream = new ByteArrayInputStream(bytes);
# 拿到文件inputStream,可以做进一步处理
# 省略部分
其它参考:https://blog.csdn.net/dulinanaaa/article/details/89181410
Follow up to close deal