X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/58c569b968a829975b4767b7396d4b55c896fd03..77ddd1ccb62e8b70580b8f410dda703a269f224f:/src/com/owncloud/android/operations/ChunkedUploadFileOperation.java?ds=inline diff --git a/src/com/owncloud/android/operations/ChunkedUploadFileOperation.java b/src/com/owncloud/android/operations/ChunkedUploadFileOperation.java index c01ee46b..d421803a 100644 --- a/src/com/owncloud/android/operations/ChunkedUploadFileOperation.java +++ b/src/com/owncloud/android/operations/ChunkedUploadFileOperation.java @@ -29,6 +29,7 @@ import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.methods.PutMethod; import com.owncloud.android.datamodel.OCFile; +import com.owncloud.android.network.ProgressiveDataTransferer; import android.accounts.Account; import android.util.Log; @@ -62,16 +63,16 @@ public class ChunkedUploadFileOperation extends UploadFileOperation { File file = new File(getStoragePath()); raf = new RandomAccessFile(file, "r"); channel = raf.getChannel(); - ChunkFromFileChannelRequestEntity entity = new ChunkFromFileChannelRequestEntity(channel, getMimeType(), CHUNK_SIZE, file); - entity.addOnDatatransferProgressListeners(getDataTransferListeners()); + mEntity = new ChunkFromFileChannelRequestEntity(channel, getMimeType(), CHUNK_SIZE, file); + ((ProgressiveDataTransferer)mEntity).addDatatransferProgressListeners(getDataTransferListeners()); long offset = 0; String uriPrefix = client.getBaseUri() + WebdavUtils.encodePath(getRemotePath()) + "-chunking-" + Math.abs((new Random()).nextInt(9000)+1000) + "-" ; long chunkCount = (long) Math.ceil((double)file.length() / CHUNK_SIZE); for (int chunkIndex = 0; chunkIndex < chunkCount ; chunkIndex++, offset += CHUNK_SIZE) { mPutMethod = new PutMethod(uriPrefix + chunkCount + "-" + chunkIndex); mPutMethod.addRequestHeader(OC_CHUNKED_HEADER, OC_CHUNKED_HEADER); - entity.setOffset(offset); - mPutMethod.setRequestEntity(entity); + ((ChunkFromFileChannelRequestEntity)mEntity).setOffset(offset); + mPutMethod.setRequestEntity(mEntity); status = client.executeMethod(mPutMethod); client.exhaustResponse(mPutMethod.getResponseBodyAsStream()); Log.d(TAG, "Upload of " + getStoragePath() + " to " + getRemotePath() + ", chunk index " + chunkIndex + ", count " + chunkCount + ", HTTP result status " + status);