mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Support removal of files from specific space
This commit is contained in:
parent
2c18e7b679
commit
9c844aae7e
@ -68,13 +68,13 @@ class CreateRemoteFolderOperation(
|
|||||||
var result: RemoteOperationResult<Unit>
|
var result: RemoteOperationResult<Unit>
|
||||||
try {
|
try {
|
||||||
val webDavUri = if (isChunksFolder) {
|
val webDavUri = if (isChunksFolder) {
|
||||||
client.uploadsWebDavUri
|
client.uploadsWebDavUri.toString()
|
||||||
} else {
|
} else {
|
||||||
client.userFilesWebDavUri
|
spaceWebDavUrl ?: client.userFilesWebDavUri.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
val mkCol = MkColMethod(
|
val mkCol = MkColMethod(
|
||||||
URL(webDavUri.toString() + WebdavUtils.encodePath(remotePath))
|
URL(webDavUri + WebdavUtils.encodePath(remotePath))
|
||||||
).apply {
|
).apply {
|
||||||
setReadTimeout(READ_TIMEOUT, TimeUnit.SECONDS)
|
setReadTimeout(READ_TIMEOUT, TimeUnit.SECONDS)
|
||||||
setConnectionTimeout(CONNECTION_TIMEOUT, TimeUnit.SECONDS)
|
setConnectionTimeout(CONNECTION_TIMEOUT, TimeUnit.SECONDS)
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
package com.owncloud.android.lib.resources.files
|
package com.owncloud.android.lib.resources.files
|
||||||
|
|
||||||
import android.net.Uri
|
|
||||||
import com.owncloud.android.lib.common.OwnCloudClient
|
import com.owncloud.android.lib.common.OwnCloudClient
|
||||||
import com.owncloud.android.lib.common.http.HttpConstants.HTTP_NO_CONTENT
|
import com.owncloud.android.lib.common.http.HttpConstants.HTTP_NO_CONTENT
|
||||||
import com.owncloud.android.lib.common.http.HttpConstants.HTTP_OK
|
import com.owncloud.android.lib.common.http.HttpConstants.HTTP_OK
|
||||||
@ -46,7 +45,8 @@ import java.net.URL
|
|||||||
* @author Abel García de Prada
|
* @author Abel García de Prada
|
||||||
*/
|
*/
|
||||||
open class RemoveRemoteFileOperation(
|
open class RemoveRemoteFileOperation(
|
||||||
private val remotePath: String
|
private val remotePath: String,
|
||||||
|
val spaceWebDavUrl: String? = null,
|
||||||
) : RemoteOperation<Unit>() {
|
) : RemoteOperation<Unit>() {
|
||||||
|
|
||||||
override fun run(client: OwnCloudClient): RemoteOperationResult<Unit> {
|
override fun run(client: OwnCloudClient): RemoteOperationResult<Unit> {
|
||||||
@ -54,7 +54,7 @@ open class RemoveRemoteFileOperation(
|
|||||||
try {
|
try {
|
||||||
val srcWebDavUri = getSrcWebDavUriForClient(client)
|
val srcWebDavUri = getSrcWebDavUriForClient(client)
|
||||||
val deleteMethod = DeleteMethod(
|
val deleteMethod = DeleteMethod(
|
||||||
URL(srcWebDavUri.toString() + WebdavUtils.encodePath(remotePath))
|
URL(srcWebDavUri + WebdavUtils.encodePath(remotePath))
|
||||||
)
|
)
|
||||||
val status = client.executeHttpMethod(deleteMethod)
|
val status = client.executeHttpMethod(deleteMethod)
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ open class RemoveRemoteFileOperation(
|
|||||||
* For standard removals, we will use [OwnCloudClient.getUserFilesWebDavUri].
|
* For standard removals, we will use [OwnCloudClient.getUserFilesWebDavUri].
|
||||||
* In case we need a different source Uri, override this method.
|
* In case we need a different source Uri, override this method.
|
||||||
*/
|
*/
|
||||||
open fun getSrcWebDavUriForClient(client: OwnCloudClient): Uri = client.userFilesWebDavUri
|
open fun getSrcWebDavUriForClient(client: OwnCloudClient): String = spaceWebDavUrl ?: client.userFilesWebDavUri.toString()
|
||||||
|
|
||||||
private fun isSuccess(status: Int) = status.isOneOf(HTTP_OK, HTTP_NO_CONTENT)
|
private fun isSuccess(status: Int) = status.isOneOf(HTTP_OK, HTTP_NO_CONTENT)
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.owncloud.android.lib.resources.files.chunks
|
package com.owncloud.android.lib.resources.files.chunks
|
||||||
|
|
||||||
import android.net.Uri
|
|
||||||
import com.owncloud.android.lib.common.OwnCloudClient
|
import com.owncloud.android.lib.common.OwnCloudClient
|
||||||
import com.owncloud.android.lib.resources.files.RemoveRemoteFileOperation
|
import com.owncloud.android.lib.resources.files.RemoveRemoteFileOperation
|
||||||
|
|
||||||
class RemoveRemoteChunksFolderOperation(remotePath: String) : RemoveRemoteFileOperation(remotePath) {
|
class RemoveRemoteChunksFolderOperation(remotePath: String) : RemoveRemoteFileOperation(remotePath) {
|
||||||
override fun getSrcWebDavUriForClient(client: OwnCloudClient): Uri = client.uploadsWebDavUri
|
override fun getSrcWebDavUriForClient(client: OwnCloudClient): String = client.uploadsWebDavUri.toString()
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,8 @@ interface FileService : Service {
|
|||||||
): RemoteOperationResult<ArrayList<RemoteFile>>
|
): RemoteOperationResult<ArrayList<RemoteFile>>
|
||||||
|
|
||||||
fun removeFile(
|
fun removeFile(
|
||||||
remotePath: String
|
remotePath: String,
|
||||||
|
spaceWebDavUrl: String? = null,
|
||||||
): RemoteOperationResult<Unit>
|
): RemoteOperationResult<Unit>
|
||||||
|
|
||||||
fun renameFile(
|
fun renameFile(
|
||||||
|
@ -111,10 +111,12 @@ class OCFileService(override val client: OwnCloudClient) : FileService {
|
|||||||
).execute(client)
|
).execute(client)
|
||||||
|
|
||||||
override fun removeFile(
|
override fun removeFile(
|
||||||
remotePath: String
|
remotePath: String,
|
||||||
|
spaceWebDavUrl: String?,
|
||||||
): RemoteOperationResult<Unit> =
|
): RemoteOperationResult<Unit> =
|
||||||
RemoveRemoteFileOperation(
|
RemoveRemoteFileOperation(
|
||||||
remotePath = remotePath
|
remotePath = remotePath,
|
||||||
|
spaceWebDavUrl = spaceWebDavUrl,
|
||||||
).execute(client)
|
).execute(client)
|
||||||
|
|
||||||
override fun renameFile(
|
override fun renameFile(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user