-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Crash when field data
is missing in formdata
#90
Comments
Btw what I'm going right now to wrap the uri is the following: const uri = imageUri.replace('file://', '').replace('file:/', ''); // remove the file:/ or file://
const wrappedUri = rnfb.wrap(uri);
let formData = [];
formData.push({
name,
filename,
type: 'image/jpeg',
data: wrappedUri
});
rnfb.fetch('POST', BASE_URL + '/file', {
'Content-Type': 'multipart/form-data'
}, formData)
.then(res => {
//...
})
.catch(e => {
//...
}); What do you think, could using the single file upload instead of formData solve the problem? |
@timsuchanek , thanks for reporting and detailed information ! About the first quest, I think we should check if the field has key As for second question, Basically, our native fs API can handle the following types of URI :
If you're wrapping an URI with prefix |
@wkh237, Regarding quest 1: Regarding quest 2: The problem currently only occurs to my users on the Xperia Z3 Compact and the Galaxy S7. As I currently don't have access to those phones, I can't reproduce the bug. |
I'm agree with you, perhaps simply show message in yellow box is pretty enough. Besides, I just realized there's a private class called To prevent app crash 😄 As for the URI problem, after some investigation I found a StackOverflow thread, there're many comments under the +457 answer saying that, the way we're using to get the absolute path of a content:// URI does not working properly. I think I can try to find an alternative way to do this. |
Uh, that I found a pretty sophisticated path resolver here: I have been using it in my image resizer in production already, where it's working perfectly.
So I think just unashamed stealing that code for I will just try that! Another question, just about the understanding: Why do you need the Edit: So the method I have to replace is the |
That sounds great !! You can just replace the Uh .. the reason why |
So that means when I have an URI already, I don't need the |
For example, if the request body is a file path, it should be
more examples
|
Ok, so only filtering |
@timsuchanek , yes 👍 |
Prevent app crash when form data contains undefined data field #90 .
Use a more sophisticated implementation as @timsuchanek mentioned in #90
@timsuchanek , I've published a |
Haha nice, yeah I implemented a version by myself, pretty same code. |
When compiling your new beta I get this:
Edit: I see that in master you have commented that line: |
@timsuchanek , the error is due to the new added prelink script in EDIT looks like RN 0.31 does not close the response body when request not success facebook/react-native#9478 which causes leaking. |
@timsuchanek , I've published |
@wkh237 Ok, yeah the |
Hi, when constructing a formData object that I pass in intro
rnfb.fetch('POST'...
, and having thedata
attribute missing, the library crashes:I know that is not the newest version of rnfb, but it still should happen in the newest as that code didn't change in the
writeTo
method of theRNFetchBlobBody
.So a simple check
field.hasKey("data")
and rejecting the promise when not would be enough, but where would you put that logic? You know better then me.Another point, the source of my problem was, that
rnfb.wrap(uri)
didn't work properly, probably returnedundefined
, as I'm using it to get a file.I don't know the specific uri yet that the user took, but the user used Android 6.0 and definitely could access the file via cameraroll.
I try to construct an uri that can reproduce the bug, but wanted you to know this bug already.
Thanks!
The text was updated successfully, but these errors were encountered: