|
@@ -1,15 +1,37 @@
|
|
|
+/* 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 <http://www.gnu.org/licenses/>.
|
|
|
+ *
|
|
|
+ */
|
|
|
+
|
|
|
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.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;
|
|
|
|
|
|
import android.net.Uri;
|
|
|
import android.os.Bundle;
|
|
|
+import android.os.Environment;
|
|
|
import android.app.Activity;
|
|
|
import android.view.Menu;
|
|
|
|
|
@@ -105,4 +127,23 @@ public class TestActivity extends Activity {
|
|
|
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;
|
|
|
+ }
|
|
|
+
|
|
|
}
|