0
我想爲上傳文件到服務器發出「PUT」請求。 對於這個我使用HttpURLConnection的,但它不是working.I給下面HttpURLConnection方法setDoOutput()在設置true後也總是返回false
public static String sendFileToServer(String filePath, String targetUrl)
{
URL url = new URL(targetUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setInstanceFollowRedirects(false);
connection.setRequestMethod("PUT");
connection.setUseCaches(false);
connection.setRequestProperty("Connection", "Keep-Alive");
connection.setRequestProperty("Cache-Control", "no-cache");
}
這是我的代碼的代碼,但連接方法我得到的是
doOutput = false
和
method = {[email protected]} "GET"
我試圖解決,但它無法正常工作。請幫助
HttpRequest方法不可用 – Aayushi
HttpRequest - 具有標頭的自定義包裝類。 –
好吧,會嘗試 – Aayushi