From: masensio Date: Wed, 18 Dec 2013 09:04:42 +0000 (+0100) Subject: Merge branch 'develop' into refactor_remote_operation_to_download_file X-Git-Tag: oc-android-1.5.5~100^2 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/71430eb7b15c982cb6b634efa5cac8348b2cd22c?ds=inline;hp=--cc Merge branch 'develop' into refactor_remote_operation_to_download_file Conflicts: oc_framework-test-project/AndroidManifest.xml oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java --- 71430eb7b15c982cb6b634efa5cac8348b2cd22c diff --cc oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java index 4fe3cd3b,c42aca2e..11f74cf2 --- a/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java +++ b/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java @@@ -1,30 -1,10 +1,31 @@@ +/* ownCloud Android client application + * Copyright (C) 2012-2013 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.oc_framework_test_project; +import java.io.File; + import com.owncloud.android.oc_framework.network.webdav.OwnCloudClientFactory; import com.owncloud.android.oc_framework.network.webdav.WebdavClient; +import com.owncloud.android.oc_framework.operations.RemoteFile; import com.owncloud.android.oc_framework.operations.RemoteOperationResult; + import com.owncloud.android.oc_framework.operations.remote.ChunkedUploadRemoteFileOperation; import com.owncloud.android.oc_framework.operations.remote.CreateRemoteFolderOperation; +import com.owncloud.android.oc_framework.operations.remote.DownloadRemoteFileOperation; import com.owncloud.android.oc_framework.operations.remote.ReadRemoteFolderOperation; import com.owncloud.android.oc_framework.operations.remote.RemoveRemoteFileOperation; import com.owncloud.android.oc_framework.operations.remote.RenameRemoteFileOperation; @@@ -128,23 -108,24 +131,43 @@@ public class TestActivity extends Activ return result; } + /** + * Access to the library method to Download a File + * @param remotePath + * + * @return + */ + public RemoteOperationResult downloadFile(RemoteFile remoteFile, String temporalFolder) { + // Create folder + String path = "/owncloud/tmp/" + temporalFolder; + File sdCard = Environment.getExternalStorageDirectory(); + File folder = new File(sdCard.getAbsolutePath() + "/" + path); + folder.mkdirs(); + + DownloadRemoteFileOperation downloadOperation = new DownloadRemoteFileOperation(remoteFile, folder.getAbsolutePath()); + RemoteOperationResult result = downloadOperation.execute(mClient); + + return result; + } + + /** Access to the library method to Upload a File + * @param storagePath + * @param remotePath + * @param mimeType + * + * @return + */ + public RemoteOperationResult uploadFile(String storagePath, String remotePath, String mimeType) { + + UploadRemoteFileOperation uploadOperation; + if (mChunked) { + uploadOperation = new ChunkedUploadRemoteFileOperation(storagePath, remotePath, mimeType); + } else { + uploadOperation = new UploadRemoteFileOperation(storagePath, remotePath, mimeType); + } + + RemoteOperationResult result = uploadOperation.execute(mClient); + + return result; + } }