- put = new PutMethod(uriPrefix + chunkCount + "-" + chunkIndex);
- put.addRequestHeader(OC_CHUNKED_HEADER, OC_CHUNKED_HEADER);
- entity.setOffset(offset);
- put.setRequestEntity(entity);
- status = client.executeMethod(put);
- client.exhaustResponse(put.getResponseBodyAsStream());
- Log.d(TAG, "Upload of " + getLocalPath() + " to " + getRemotePath() + ", chunk index " + chunkIndex + ", count " + chunkCount + ", HTTP result status " + status);
+ if (mPutMethod != null) {
+ mPutMethod.releaseConnection(); // let the connection available for other methods
+ }
+ mPutMethod = new PutMethod(uriPrefix + chunkCount + "-" + chunkIndex);
+ mPutMethod.addRequestHeader(OC_CHUNKED_HEADER, OC_CHUNKED_HEADER);
+ ((ChunkFromFileChannelRequestEntity)mEntity).setOffset(offset);
+ mPutMethod.setRequestEntity(mEntity);
+ status = client.executeMethod(mPutMethod);
+ client.exhaustResponse(mPutMethod.getResponseBodyAsStream());
+ Log_OC.d(TAG, "Upload of " + getStoragePath() + " to " + getRemotePath() + ", chunk index " + chunkIndex + ", count " + chunkCount + ", HTTP result status " + status);