mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 02:17:41 +00:00 
			
		
		
		
	Add copy operation to the file service
This commit is contained in:
		
							parent
							
								
									34cc4c87b1
								
							
						
					
					
						commit
						4c39990edb
					
				| @ -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)), | ||||
|  | ||||
| @ -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, | ||||
|  | ||||
| @ -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, | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user