diff --git a/app/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.kt b/app/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.kt
index d422814b52f4..834de5573346 100644
--- a/app/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.kt
+++ b/app/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.kt
@@ -456,7 +456,7 @@ open class FolderPickerActivity :
targetFilePaths?.let { filePaths ->
if (!isFolderAndFilePathsValid(filePaths)) {
- DisplayUtils.showSnackMessage(this, R.string.file_name_validator_error_copy_or_move)
+ DisplayUtils.showSnackMessage(this, R.string.file_name_validator_error_contains_reserved_names_or_invalid_characters)
Handler(Looper.getMainLooper()).postDelayed({
setResult(RESULT_CANCELED, resultData)
finish()
diff --git a/app/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java
index 1b6f0d7d62c2..248935e3deef 100755
--- a/app/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java
+++ b/app/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java
@@ -671,7 +671,7 @@ public void onClick(View v) {
boolean isPathValid = FileNameValidator.INSTANCE.checkFolderPath(mUploadPath, getCapabilities(), this);
if (!isPathValid) {
- DisplayUtils.showSnackMessage(this, R.string.file_name_validator_error_copy_or_move);
+ DisplayUtils.showSnackMessage(this, R.string.file_name_validator_error_contains_reserved_names_or_invalid_characters);
return;
}
diff --git a/app/src/main/java/com/owncloud/android/ui/helpers/UriUploader.kt b/app/src/main/java/com/owncloud/android/ui/helpers/UriUploader.kt
index 3db05a6805e8..e58b8b5155dc 100644
--- a/app/src/main/java/com/owncloud/android/ui/helpers/UriUploader.kt
+++ b/app/src/main/java/com/owncloud/android/ui/helpers/UriUploader.kt
@@ -15,6 +15,7 @@ import android.net.Uri
import android.os.Parcelable
import com.nextcloud.client.account.User
import com.nextcloud.client.jobs.upload.FileUploadHelper
+import com.nextcloud.utils.fileNameValidator.FileNameValidator
import com.owncloud.android.R
import com.owncloud.android.files.services.NameCollisionPolicy
import com.owncloud.android.lib.common.utils.Log_OC
@@ -23,6 +24,7 @@ import com.owncloud.android.ui.activity.FileActivity
import com.owncloud.android.ui.asynctasks.CopyAndUploadContentUrisTask
import com.owncloud.android.ui.asynctasks.CopyAndUploadContentUrisTask.OnCopyTmpFilesTaskListener
import com.owncloud.android.ui.fragment.TaskRetainerFragment
+import com.owncloud.android.utils.DisplayUtils
import com.owncloud.android.utils.UriUtils.getDisplayNameForUri
/**
@@ -70,9 +72,26 @@ class UriUploader(
Log_OC.e(TAG, "Sensitive URI detected, aborting upload.")
code = UriUploaderResultCode.ERROR_SENSITIVE_PATH
} else {
- val uris = mUrisToUpload.filterNotNull()
+ var isInvalidPathMessageDisplayed = false
+ val uris = mUrisToUpload
+ .filterNotNull()
.map { it as Uri }
.map { Pair(it, getRemotePathForUri(it)) }
+ .filter { (_, filename) ->
+ val isValid = (FileNameValidator.checkFileName(
+ filename.removePrefix("/"),
+ mActivity.capabilities,
+ mActivity, null
+ ) == null)
+ if (!isValid && !isInvalidPathMessageDisplayed) {
+ isInvalidPathMessageDisplayed = true
+ DisplayUtils.showSnackMessage(
+ mActivity,
+ R.string.file_name_validator_upload_content_error
+ )
+ }
+ isValid
+ }
val fileUris = uris
.filter { it.first.scheme == ContentResolver.SCHEME_FILE }
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index ba8ca85d0ccd..1c8396cfa848 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1209,7 +1209,8 @@
Secure sharing is not set up for this user
Resharing is not allowed during secure file drop
- Folder path contains reserved names or invalid character
+ Some contents cannot able to uploaded due to contains reserved names or invalid character.
+ Folder path contains reserved names or invalid character
File name contains invalid characters: %s
%s is a reserved name
File name ends with a space or a period