| | |
| | | |
| | | @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()); |
| | |
| | | |
| | | ResponseEntity<String> responseEntity = new ResponseEntity<String>(outParam.toJSONString(), HttpStatus.OK); |
| | | return responseEntity; |
| | | } finally { |
| | | if (is != null) { |
| | | try { |
| | | is.close(); |
| | | } catch (Exception e) { |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |