Skip to content

Commit 3373cd9

Browse files
authored
fix: Mitigate Android ERR_UPLOAD_FILE_CHANGE errors (#22347)
* fix: Mitigate Android ERR_UPLOAD_FILE_CHANGE errors A Chrome bug results in `ERR_UPLOAD_FILE_CHANGED` errors when selecting a file from a cloud content provider (e.g., the Google Drive app). This does not disrupt all file uploads--e.g., images--but larger files (e.g., videos) and resumable uploads often fail. Caching the selected file ensures the file remains stable throughout the Chrome upload process. See: https://issues.chromium.org/issues/40123366 * build: Update GutenbergKit version
1 parent a18c70b commit 3373cd9

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

WordPress/src/main/java/org/wordpress/android/ui/posts/editor/GutenbergKitEditorFragment.kt

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import android.app.Activity
44
import android.content.Context
55
import android.content.Intent
66
import android.content.res.Configuration
7-
import android.net.Uri
87
import android.os.Bundle
98
import android.text.Editable
109
import android.view.LayoutInflater
@@ -16,7 +15,9 @@ import android.view.ViewGroup
1615
import android.webkit.URLUtil
1716
import androidx.core.util.Pair
1817
import androidx.lifecycle.LiveData
18+
import androidx.lifecycle.lifecycleScope
1919
import com.google.gson.Gson
20+
import kotlinx.coroutines.launch
2021
import org.wordpress.android.R
2122
import org.wordpress.android.editor.BuildConfig
2223
import org.wordpress.android.editor.EditorEditMediaListener
@@ -234,24 +235,17 @@ class GutenbergKitEditorFragment : GutenbergKitEditorFragmentBase() {
234235
private fun handleFileChooserResult(gutenbergView: GutenbergView, resultCode: Int, data: Intent?) {
235236
val filePathCallback = gutenbergView.filePathCallback ?: return
236237

237-
val uris = extractUrisFromIntent(resultCode, data)
238-
filePathCallback.onReceiveValue(uris)
239-
gutenbergView.resetFilePathCallback()
240-
}
241-
242-
private fun extractUrisFromIntent(resultCode: Int, data: Intent?): Array<Uri?>? {
243-
if (resultCode != Activity.RESULT_OK || data == null) {
244-
return null
238+
if (resultCode != Activity.RESULT_OK) {
239+
filePathCallback.onReceiveValue(null)
240+
gutenbergView.resetFilePathCallback()
241+
return
245242
}
246243

247-
return when {
248-
data.clipData != null -> {
249-
val clipData = data.clipData!!
250-
Array(clipData.itemCount) { i -> clipData.getItemAt(i).uri }
251-
}
252-
253-
data.data != null -> arrayOf(data.data)
254-
else -> null
244+
lifecycleScope.launch {
245+
val uris = gutenbergView.extractUrisFromIntent(data)
246+
val processedUris = gutenbergView.processFileUris(requireContext(), uris)
247+
filePathCallback.onReceiveValue(processedUris)
248+
gutenbergView.resetFilePathCallback()
255249
}
256250
}
257251

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ google-play-services-auth = '20.4.1'
7373
google-services = '4.4.4'
7474
gravatar = '2.5.0'
7575
greenrobot-eventbus = '3.3.1'
76-
gutenberg-kit = 'v0.10.0'
76+
gutenberg-kit = 'v0.10.2'
7777
gutenberg-mobile = 'v1.121.0'
7878
indexos-media-for-mobile = '43a9026f0973a2f0a74fa813132f6a16f7499c3a'
7979
jackson-databind = '2.12.7.1'

0 commit comments

Comments
 (0)