private static final Logger log = LoggerFactory.getLogger(LessonDocTest.class);
/**
* 上传文档到某个课节
* @throws IOException
*/
@Test
public void testUploadDoc() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId=super.appId;
String appSecret=super.appSecret;
String userId = super.userId;
String timestamp=String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/hi-class-api/open/file/v1/upload-doc";
String lessonId = "1965681";
String type = "common";
String docName = "test";
String callbackUrl = "http://www.baidu.com";
String path = getClass().getResource("/file/").getPath() + "report.pdf";
File file = new File("D:/test.pdf");
//http 调用逻辑
Map<String,String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp",timestamp);
requestMap.put("lessonId",lessonId);
Map<String,File> fileMap = new HashMap<>();
fileMap.put("file",file);
requestMap.put("type",type);
requestMap.put("docName",docName);
requestMap.put("callbackUrl",callbackUrl);
requestMap.put("sign",LiveSignUtil.getSign(requestMap, appSecret));
String response = HttpUtil.postFile(url, requestMap,fileMap,"utf-8");
log.info("测试上传文档到某个课节:{}",response);
//do somethings
}