zoukankan      html  css  js  c++  java
  • 使用代码上传文件示例

    public Map<String, Object> sendGrantToCrm(String custNo, String cardNo, String path, String fileName) {
    
            FileSystemResource fileSystemResource = new FileSystemResource(path + fileName);
            MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>();
            Map<String, Object> resultMap = new HashMap<>();
            try {
                InputStream is = new BufferedInputStream(new FileInputStream(path + fileName));
                String md5 = DigestUtils.md5Hex(IOUtils.toByteArray(is));
                IOUtils.closeQuietly(is);
    
                String crmUrl = EurekaServer.CRM + "/app/crm/cust/arch/upload?custNo=" + custNo
                        + "&cardNo=" + cardNo + "&archType=1" + "&fileName=" + fileName + "&md5=" + md5;
                HttpHeaders headers = new HttpHeaders();
                paramMap.add("file", fileSystemResource);
                HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(paramMap, headers);
                ResponseEntity entity = restTemplate.exchange(crmUrl, HttpMethod.POST, httpEntity, Map.class);
                Map<String, Object> crmRetMap = (Map<String, Object>) entity.getBody();
                logger.info("授权书发送CRM:entity=" + crmRetMap);
    
                if (!"00000".equals(((Map<String, Object>) crmRetMap.get("head")).get("retFlag"))) {
                    resultMap.put("retCod", "00001");
                    resultMap.put("retMsg", ((Map<String, Object>) entity.getBody()).get("retMsg"));
                    return resultMap;
                }
            } catch (Exception e) {
                logger.error("文件上传CRM异常!" + e.getMessage());
                resultMap.put("retCod", "00002");
                resultMap.put("retMsg", "文件上传CRM异常!");
                return resultMap;
            }
            resultMap.put("retCod", "00000");
            return resultMap;
        }
    
  • 相关阅读:
    鼠标移上与移出事件
    最小高度 最大高度
    鼠标移上改变光标
    设置圆角
    iframe 子窗口获取父窗口元素 父窗口获取子窗口元素
    parent
    禁用滚动条
    mysql--user表
    mysql客户端连不上数据库
    linux下安装MySQL
  • 原文地址:https://www.cnblogs.com/lu51211314/p/11322121.html
Copyright © 2011-2022 走看看