|
@ -10,6 +10,7 @@ import com.yihu.hos.core.log.LoggerFactory;
|
|
|
import org.apache.http.HttpEntity;
|
|
|
import org.apache.http.client.config.RequestConfig;
|
|
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
import org.apache.http.client.methods.HttpDelete;
|
|
|
import org.apache.http.client.methods.HttpGet;
|
|
|
import org.apache.http.client.methods.HttpPost;
|
|
|
import org.apache.http.entity.ContentType;
|
|
@ -329,24 +330,20 @@ public class ClassFileUtil {
|
|
|
*/
|
|
|
public static boolean deleteFile(String url) {
|
|
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
|
HttpPost httpPost = new HttpPost(url);
|
|
|
HttpDelete httpDelete = new HttpDelete(url);
|
|
|
CloseableHttpResponse response = null;
|
|
|
HttpEntity entity = null;
|
|
|
try {
|
|
|
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(1000 * 60 * 5).setConnectTimeout(1000 * 60 * 5).build();//设置请求和传输超时时间
|
|
|
httpPost.setConfig(requestConfig);
|
|
|
response = httpClient.execute(httpPost);
|
|
|
httpDelete.setConfig(requestConfig);
|
|
|
response = httpClient.execute(httpDelete);
|
|
|
response.setHeader("Content-Type", "application/json;charset=UTF-8");
|
|
|
entity = response.getEntity();
|
|
|
int code = response.getStatusLine().getStatusCode();
|
|
|
Map<String, Object> responMap = parseRespon(entity);
|
|
|
if (code == 200) {
|
|
|
boolean succ = (boolean) responMap.get("successFlg");
|
|
|
if (!succ) {
|
|
|
System.out.println("请求成功,删除失败!message:" + responMap.get("message").toString());
|
|
|
;
|
|
|
}
|
|
|
return succ;
|
|
|
System.out.println("请求成功,文件删除成功!body:" + response.getEntity().toString());
|
|
|
return true;
|
|
|
|
|
|
} else {
|
|
|
System.out.println("删除请求失败,status:" + code);
|
|
|
return false;
|