RestTemplate远程调用文件删除
文件删除
需要header不需要form表单的情况
/**
* 文件删除
*
* @return
*/
@GetMapping("/delete")
@ResponseBody
public String delete() {
String result = null;
try {
String URL = "you url";
//设置请求
HttpHeaders headers = new HttpHeaders();
String token = "your token ";
headers.add("your_token_key", token);
//封装请求报文
HttpEntity<MultiValueMap<String, Object>> files = new HttpEntity<>(null, headers);
result = restTemplate.postForObject(URL, files, String.class);
log.debug("result is " + result);
} catch (Exception e) {
e.printStackTrace();
}
return result;
}