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

Upload workers and network operations adapted to spaces

This commit is contained in:
Juan Carlos Garrote 2023-02-15 14:54:59 +01:00
parent a395787e0b
commit e6f3fd2e16

View File

@ -1,5 +1,5 @@
/* ownCloud Android Library is available under MIT license /* ownCloud Android Library is available under MIT license
* Copyright (C) 2022 ownCloud GmbH. * Copyright (C) 2023 ownCloud GmbH.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@ -48,6 +48,7 @@ import java.util.concurrent.atomic.AtomicBoolean
* @author masensio * @author masensio
* @author David González Verdugo * @author David González Verdugo
* @author Abel García de Prada * @author Abel García de Prada
* @author Juan Carlos Garrote Gascón
*/ */
open class UploadFileFromFileSystemOperation( open class UploadFileFromFileSystemOperation(
val localPath: String, val localPath: String,
@ -55,6 +56,7 @@ open class UploadFileFromFileSystemOperation(
val mimeType: String, val mimeType: String,
val lastModifiedTimestamp: String, val lastModifiedTimestamp: String,
val requiredEtag: String?, val requiredEtag: String?,
val spaceWebDavUrl: String? = null,
) : RemoteOperation<Unit>() { ) : RemoteOperation<Unit>() {
protected val cancellationRequested = AtomicBoolean(false) protected val cancellationRequested = AtomicBoolean(false)
@ -97,7 +99,8 @@ open class UploadFileFromFileSystemOperation(
synchronized(dataTransferListener) { it.addDatatransferProgressListeners(dataTransferListener) } synchronized(dataTransferListener) { it.addDatatransferProgressListeners(dataTransferListener) }
} }
putMethod = PutMethod(URL(client.userFilesWebDavUri.toString() + WebdavUtils.encodePath(remotePath)), fileRequestBody!!).apply { val baseStringUrl = spaceWebDavUrl ?: client.userFilesWebDavUri.toString()
putMethod = PutMethod(URL(baseStringUrl + WebdavUtils.encodePath(remotePath)), fileRequestBody!!).apply {
retryOnConnectionFailure = false retryOnConnectionFailure = false
if (!requiredEtag.isNullOrBlank()) { if (!requiredEtag.isNullOrBlank()) {
addRequestHeader(HttpConstants.IF_MATCH_HEADER, requiredEtag) addRequestHeader(HttpConstants.IF_MATCH_HEADER, requiredEtag)