private String eval(String input) { BufferedReader reader; String sessionUrl = url.toString() + sessionId; PutMethod method = new PutMethod(sessionUrl); String result = ""; try { RequestEntity entity = new StringRequestEntity(input, "text/plain", "UTF-8"); method.setRequestEntity(entity); client.executeMethod(method); reader = new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream())); String line; while (((line = reader.readLine()) != null)) { result = result + line; } } catch (HttpException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } finally { method.releaseConnection(); } return result; }
protected RemoteOperationResult uploadFile(OwnCloudClient client) throws IOException { int status; RemoteOperationResult result; try { File f = new File(localPath); entity = new FileRequestEntity(f, mimeType); synchronized (dataTransferListeners) { ((ProgressiveDataTransfer) entity) .addDataTransferProgressListeners(dataTransferListeners); } if (requiredEtag != null && requiredEtag.length() > 0) { putMethod.addRequestHeader(IF_MATCH_HEADER, "\"" + requiredEtag + "\""); } putMethod.addRequestHeader(OC_TOTAL_LENGTH_HEADER, String.valueOf(f.length())); putMethod.addRequestHeader(OC_X_OC_MTIME_HEADER, lastModificationTimestamp); putMethod.setRequestEntity(entity); status = client.executeMethod(putMethod); result = new RemoteOperationResult(isSuccess(status), putMethod); client.exhaustResponse(putMethod.getResponseBodyAsStream()); } finally { putMethod.releaseConnection(); // let the connection available for other methods } return result; }
client.exhaustResponse(putMethod.getResponseBodyAsStream()); Log_OC.d(TAG, "Upload of " + localPath + " to " + remotePath + ", chunk from " + startString + " to " + endString + " size: " + chunk.length() + ", HTTP result status " + status);
} else { result = new RemoteOperationResult(false, putMethod); client.exhaustResponse(putMethod.getResponseBodyAsStream());