Use getErrorStream() if status code is >= 400 in uploadFiles
The current state of the Java Uploader is to always use connection.getInputStream() for any response in the RNFS.uploadFiles.
This behavior makes handling the different status code or any error message inside the response body impossible.
In my use case, the server would send status code 500 if I uploaded the wrong file type, but if we use connection.getInputStream() when the server returns >= 400 status code, ENOENT error will happen (see here).
To fix this, we use connection.getErrorStream() whenever the server returns >= 400 status code.
Disclaimer: I am not experienced in Java programming, please help me to review or improve anything there is to improve.
Can you help checking this @itinance? Thanks!
Any update on this? I cannot upload photos to Cloudinary.
@psamim You can use patch-package to modify installed node modules before this PR merged (I doubt it will be merged soon).
Anyway, looking at this issue https://github.com/itinance/react-native-fs/issues/755, there might be a problem within the code, this PR only handles non 200 response properly.
@itinance Any update on this PR ? Any error from the back-end throw an ENOENT which doesn't allow good error management (400, 401, 403, 409, 429, ...)