Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix RequestBodyUtil for older version of Android (M or before) (#28399)
Summary: This is bugfix for following code in RequestBodyUtil.java. ``` stream.getChannel().transferFrom(channel, 0, Long.MAX_VALUE); ``` This throws IllegalArgumentException in Android M or before. It seems in old version of JVM it internally casts third argument to integer so when you pass value that is larger than Integer.MAX_VALUE app would crash. See: https://bugs.openjdk.java.net/browse/JDK-5105464 https://stackoverflow.com/questions/55696035/thrown-illegalargumentexception-when-using-java-nio ## Changelog [Android] [Fixed] Fix issue downloading request body via remote URL Pull Request resolved: #28399 Test Plan: Run following code on Android M or before. It would crash w/o this PR but it won't with this PR. ``` const body = new FormData(); const image = { uri: "https://reactnative.dev/img/showcase/facebook.png", path: null }; body.append('user[img]', fileBody(image)); fetch("https://example.com", { method: 'POST', headers: { Accept: 'application/json', 'Content-Type': 'multipart/form-data;', }, body: body }); ``` Reviewed By: christophpurrer, cipolleschi Differential Revision: D45057263 Pulled By: cortinico fbshipit-source-id: e0306eb157a5aa92619ac51e67d106b8651a0ba7
- Loading branch information