后台插件上传图片,赋值给图片字段进行回显原创
金蝶云社区-蔡销
蔡销
0人赞赏了该文章 1298次浏览 未经作者许可,禁止转载编辑于2023年03月29日 21:38:50

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();

                }

            }

        }

    }


赞 0