Skip to content

Commit 9692e64

Browse files
huntiemeta-codesync[bot]
authored andcommitted
Fix binary FormData uploads on Android (#54917)
Summary: Pull Request resolved: #54917 #54804 was a late pick into 0.83 following RC feedback, but was insufficiently tested. In #54881, users report failing requests attributed to this code path when performing image uploads. Functionally revert this change, as this breaks runtime behaviour. Changelog: [Internal] Changelog (0.83): [Android][Fixed] - Fix Network error that could occur for `FormData` uploads with binary data Reviewed By: vzaidman Differential Revision: D89373824 fbshipit-source-id: 9f144f075db3f9ad5df8598d0f113655466896cf
1 parent 1ce9946 commit 9692e64

1 file changed

Lines changed: 2 additions & 17 deletions

File tree

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/network/ProgressRequestBody.kt

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ internal class ProgressRequestBody(
2323
) : RequestBody() {
2424
private var contentLength = 0L
2525

26-
companion object {
27-
private const val MAX_BODY_PREVIEW_SIZE = 1024 * 1024 // 1MB
28-
}
29-
3026
override fun contentType(): MediaType? {
3127
return requestBody.contentType()
3228
}
@@ -84,18 +80,7 @@ internal class ProgressRequestBody(
8480
}
8581

8682
fun getBodyPreview(): String {
87-
return try {
88-
val buffer = okio.Buffer()
89-
requestBody.writeTo(buffer)
90-
val size = buffer.size()
91-
if (size <= MAX_BODY_PREVIEW_SIZE) {
92-
buffer.readUtf8()
93-
} else {
94-
buffer.readUtf8(MAX_BODY_PREVIEW_SIZE.toLong()) +
95-
"\n... [truncated, showing $MAX_BODY_PREVIEW_SIZE of $size bytes]"
96-
}
97-
} catch (e: Exception) {
98-
""
99-
}
83+
// TODO: Safely implement request body previews
84+
return "[Preview unavailable]"
10085
}
10186
}

0 commit comments

Comments
 (0)