時(特別是當我有一個不好的連接)時,我獲得NonRepeatableRequestException
而 發送映像到服務器。這裏是我的代碼:NonRepeatableRequestException在發送鏡像到服務器
HttpParams params = new BasicHttpParams();
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http",
PlainSocketFactory.getSocketFactory(), 80));
DefaultHttpClient httpclient = new DefaultHttpClient(new
ThreadSafeClientConnManager(params, registry), params);
HttpPost httpPost = new HttpPost(uri);
SimpleMultipartEntity multipartContent = new SimpleMultipartEntity();
multipartContent.addPart(propName, filename, inputStream,
contentType);
httpPost.setEntity(multipartContent);
httpclient.getParams().setParameter("http.protocol.expect-continue",
false);
java.util.logging.Logger.getLogger("httpclient.wire.header").setLevel(java.util.logging.Level.FINEST);
java.util.logging.Logger.getLogger("httpclient.wire.content").setLevel(java.util.logging.Level.FINEST);
HttpResponse response = httpclient.execute(httpPost);
我意識到的InputStream是不可重複的類型,但不知道如何正確地創建請求,並避免此異常。 任何幫助,不勝感激。