mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Add copy operation to the file service
This commit is contained in:
parent
2c75099a95
commit
e5fc25c3ae
@ -51,13 +51,13 @@ import java.util.concurrent.TimeUnit
|
|||||||
class CopyRemoteFileOperation(
|
class CopyRemoteFileOperation(
|
||||||
private val srcRemotePath: String,
|
private val srcRemotePath: String,
|
||||||
private val targetRemotePath: String,
|
private val targetRemotePath: String,
|
||||||
) : RemoteOperation<String?>() {
|
) : RemoteOperation<String>() {
|
||||||
/**
|
/**
|
||||||
* Performs the rename operation.
|
* Performs the rename operation.
|
||||||
*
|
*
|
||||||
* @param client Client object to communicate with the remote ownCloud server.
|
* @param client Client object to communicate with the remote ownCloud server.
|
||||||
*/
|
*/
|
||||||
override fun run(client: OwnCloudClient): RemoteOperationResult<String?> {
|
override fun run(client: OwnCloudClient): RemoteOperationResult<String> {
|
||||||
if (targetRemotePath == srcRemotePath) {
|
if (targetRemotePath == srcRemotePath) {
|
||||||
// nothing to do!
|
// nothing to do!
|
||||||
return RemoteOperationResult(ResultCode.OK)
|
return RemoteOperationResult(ResultCode.OK)
|
||||||
@ -67,7 +67,7 @@ class CopyRemoteFileOperation(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// perform remote operation
|
/// perform remote operation
|
||||||
var result: RemoteOperationResult<String?>
|
var result: RemoteOperationResult<String>
|
||||||
try {
|
try {
|
||||||
val copyMethod = CopyMethod(
|
val copyMethod = CopyMethod(
|
||||||
URL(client.userFilesWebDavUri.toString() + WebdavUtils.encodePath(srcRemotePath)),
|
URL(client.userFilesWebDavUri.toString() + WebdavUtils.encodePath(srcRemotePath)),
|
||||||
|
@ -35,6 +35,11 @@ interface FileService : Service {
|
|||||||
isUserLogged: Boolean
|
isUserLogged: Boolean
|
||||||
): RemoteOperationResult<Boolean>
|
): RemoteOperationResult<Boolean>
|
||||||
|
|
||||||
|
fun copyFile(
|
||||||
|
sourceRemotePath: String,
|
||||||
|
targetRemotePath: String,
|
||||||
|
): RemoteOperationResult<String>
|
||||||
|
|
||||||
fun createFolder(
|
fun createFolder(
|
||||||
remotePath: String,
|
remotePath: String,
|
||||||
createFullPath: Boolean,
|
createFullPath: Boolean,
|
||||||
|
@ -26,6 +26,7 @@ package com.owncloud.android.lib.resources.files.services.implementation
|
|||||||
import com.owncloud.android.lib.common.OwnCloudClient
|
import com.owncloud.android.lib.common.OwnCloudClient
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
||||||
import com.owncloud.android.lib.resources.files.CheckPathExistenceRemoteOperation
|
import com.owncloud.android.lib.resources.files.CheckPathExistenceRemoteOperation
|
||||||
|
import com.owncloud.android.lib.resources.files.CopyRemoteFileOperation
|
||||||
import com.owncloud.android.lib.resources.files.CreateRemoteFolderOperation
|
import com.owncloud.android.lib.resources.files.CreateRemoteFolderOperation
|
||||||
import com.owncloud.android.lib.resources.files.DownloadRemoteFileOperation
|
import com.owncloud.android.lib.resources.files.DownloadRemoteFileOperation
|
||||||
import com.owncloud.android.lib.resources.files.GetUrlToOpenInWebRemoteOperation
|
import com.owncloud.android.lib.resources.files.GetUrlToOpenInWebRemoteOperation
|
||||||
@ -50,6 +51,15 @@ class OCFileService(override val client: OwnCloudClient) : FileService {
|
|||||||
override fun getUrlToOpenInWeb(openWebEndpoint: String, fileId: String): RemoteOperationResult<String> =
|
override fun getUrlToOpenInWeb(openWebEndpoint: String, fileId: String): RemoteOperationResult<String> =
|
||||||
GetUrlToOpenInWebRemoteOperation(openWithWebEndpoint = openWebEndpoint, fileId = fileId).execute(client)
|
GetUrlToOpenInWebRemoteOperation(openWithWebEndpoint = openWebEndpoint, fileId = fileId).execute(client)
|
||||||
|
|
||||||
|
override fun copyFile(
|
||||||
|
sourceRemotePath: String,
|
||||||
|
targetRemotePath: String
|
||||||
|
): RemoteOperationResult<String> =
|
||||||
|
CopyRemoteFileOperation(
|
||||||
|
srcRemotePath = sourceRemotePath,
|
||||||
|
targetRemotePath = targetRemotePath
|
||||||
|
).execute(client)
|
||||||
|
|
||||||
override fun createFolder(
|
override fun createFolder(
|
||||||
remotePath: String,
|
remotePath: String,
|
||||||
createFullPath: Boolean,
|
createFullPath: Boolean,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user