1
0
mirror of https://github.com/owncloud/android-library.git synced 2025-06-07 07:56:19 +00:00

Add copy operation to the file service

This commit is contained in:
Abel García de Prada 2021-05-25 08:56:42 +02:00 committed by Abel García de Prada
parent 34cc4c87b1
commit 4c39990edb
3 changed files with 18 additions and 3 deletions

View File

@ -51,13 +51,13 @@ import java.util.concurrent.TimeUnit
class CopyRemoteFileOperation(
private val srcRemotePath: String,
private val targetRemotePath: String,
) : RemoteOperation<String?>() {
) : RemoteOperation<String>() {
/**
* Performs the rename operation.
*
* @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) {
// nothing to do!
return RemoteOperationResult(ResultCode.OK)
@ -67,7 +67,7 @@ class CopyRemoteFileOperation(
}
/// perform remote operation
var result: RemoteOperationResult<String?>
var result: RemoteOperationResult<String>
try {
val copyMethod = CopyMethod(
URL(client.userFilesWebDavUri.toString() + WebdavUtils.encodePath(srcRemotePath)),

View File

@ -35,6 +35,11 @@ interface FileService : Service {
isUserLogged: Boolean
): RemoteOperationResult<Boolean>
fun copyFile(
sourceRemotePath: String,
targetRemotePath: String,
): RemoteOperationResult<String>
fun createFolder(
remotePath: String,
createFullPath: Boolean,

View File

@ -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.operations.RemoteOperationResult
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.DownloadRemoteFileOperation
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> =
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(
remotePath: String,
createFullPath: Boolean,