在postman中这样下载文件
有时下载文件太大postman会闪退,可以通过代码下载,使用hutool的http包
代码
public static void main(String[] args) {
//任务id
String taskId = "20240927171449895866";
//include等文件目录前缀
String targetDir = "C:\\test2\\";
//1:普通渲染 2:组合主图 3:平面户型图渲染
Integer type = 1;
//token
String token = "517cba25-a2d6-45b7-a22e-6a5c7535bff1";
//接口路径
String requestUrl = "域名/render/task/downLoad/taskFileMultiThreadDownload";
//下载压缩包目录
String zipDir = "/Users/ming/Downloads/"+taskId+".zip";
JSONObject json = new JSONObject();
json.put("renderTaskId",taskId);
json.put("targetDir",targetDir);
json.put("taskType",type);
//设置请求头
Map<String, String > heads = new HashMap<>();
heads.put("Content-Type", "application/json;charset=UTF-8");
heads.put("X-Access-Token",token);
HttpRequest request = HttpRequest.post(requestUrl).headerMap(heads,false).body(json.toJSONString());
HttpResponse response = request.execute();
response.writeBody(new File(zipDir));
//解压
//ZipUtil.unzip(zipDir);
}