Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed and added support for dataUri in form data (#33675)
Summary: Continuation of #33548 Fixes #25790. The issue resulted because the [getFileInputStream() method of RequestBodyUtil failed to return an inputStream of the given dataUri ](https://github.com/facebook/react-native/blob/16397e0d3c0dd3374ddb642599725ca41f092a8a/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.java#L427) This happened because the openInputStream() method of [context.getContentResolver() expects a content or a file](https://developer.android.com/reference/android/content/ContentResolver#openInputStream(android.net.Uri)) in its parameter but instead received dataUri which resulted in FileNotFoundException. ![issue](https://user-images.githubusercontent.com/38756320/161345967-fd79d3e2-54a8-4a0e-8a6b-189ce9883a78.jpeg) **Solution**: I've now converted the dataUri to bitmap and then attached an inputStream to the compressed bitmap. This way we won't have to store the image temporarily. I think converting the dataUri to Bitmap is necessary as there is no method that lets us convert the dataUri to inputStream directly. And regarding large size images, converting them to bitmap is the only(efficient) step I can think of, as the conversion is handled by in-built java function. This issue has been unresolved for quite some time now, so resolving this PR would be greatly appreciated. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [Android] [Added] - Support for dataUri in form data Pull Request resolved: #33675 Reviewed By: christophpurrer, mdvacca Differential Revision: D36205586 Pulled By: cortinico fbshipit-source-id: bfc83efcec0b2fcb1df42e4bf1d43c966de8f40e
- Loading branch information