java110
2023-08-22 ded40ebbd1613490fc68190dbd92db5d7243267f
service-api/src/main/java/com/java110/api/smo/file/impl/AddFileSMOImpl.java
@@ -37,13 +37,14 @@
    @Override
    public ResponseEntity<String> saveFile(IPageData pd, MultipartFile uploadFile) throws IOException {
        InputStream is = null;
        try {
        JSONObject paramIn = JSONObject.parseObject(pd.getReqData());
        if (uploadFile.getSize() > 2 * 1024 * 1024) {
            throw new IllegalArgumentException("上传文件超过两兆");
        }
        Assert.hasKeyAndValue(paramIn, "suffix", "必填,请填写文件类型");
        InputStream is = uploadFile.getInputStream();
            is = uploadFile.getInputStream();
        String fileContext = Base64Convert.ioToBase64(is);
        paramIn.put("context", fileContext);
        paramIn.put("fileName", uploadFile.getOriginalFilename());
@@ -61,6 +62,15 @@
        ResponseEntity<String> responseEntity = new ResponseEntity<String>(outParam.toJSONString(), HttpStatus.OK);
        return responseEntity;
        } finally {
            if (is != null) {
                try {
                    is.close();
                } catch (Exception e) {
                }
            }
        }
    }
    @Override