Commit c506be8c by 徐高华

自建

parent a1d25fe1
package com.gic.qywx.self; package com.gic.qywx.self;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.http.entity.ContentType; import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.content.ByteArrayBody; import org.apache.http.entity.mime.content.ByteArrayBody;
import org.apache.http.entity.mime.content.ContentBody; import org.apache.http.entity.mime.content.ContentBody;
...@@ -11,6 +18,8 @@ import org.slf4j.LoggerFactory; ...@@ -11,6 +18,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
@RestController @RestController
@RequestMapping("/qywx") @RequestMapping("/qywx")
...@@ -49,4 +58,20 @@ public class QywxController { ...@@ -49,4 +58,20 @@ public class QywxController {
return map; return map;
} }
@RequestMapping("self-upload-data")
public Object selfImage(String url, String fileName, HttpServletRequest request) throws IOException {
logger.info("自建upload-data,url={}", url);
MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
List<MultipartFile> list = multiRequest.getMultiFileMap().get("media");
MultipartFile mf = list.get(0);
byte[] data = mf.getBytes();
Map<String, ContentBody> paramsMap = new HashMap<String, ContentBody>();
paramsMap.put("media", new ByteArrayBody(data, ContentType.DEFAULT_BINARY, fileName));
Map<String, Object> map = HttpClient.getWinxinResByFile(url, paramsMap);
return map;
}
} }
server: server:
port: 8601 port: 8960
servlet: servlet:
context-path: /api-qywx-self context-path: /api-qywx-self
tomcat: tomcat:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment