1、首先要先将图片上传到系统上
2、上传完毕后,将返回的值赋值到图片字段上即可
代码如下:
private void fn12() {
//图片的数据
String imageData = "";
byte[] bytes = Base64.decodeBase64(imageData);
InputStream inputStream = null;
try {
inputStream = new ByteArrayInputStream(bytes);
//步骤1上传图片
FileService imageFileService = FileServiceFactory.getImageFileService();
//封装要上传的对象
FileItem fileItem = new FileItem("xxx.png", "cas/xxx.png", inputStream);
String imageKey = imageFileService.upload(fileItem);
this.getModel().setValue("图片字段的标识", imageKey);
this.getView().updateView("图片字段的标识");
} catch (Exception e) {
e.printStackTrace();
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
推荐阅读