-
Notifications
You must be signed in to change notification settings - Fork 24.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS - Image files included in outbound network requests are significantly larger than the original files #33760
Comments
the issue #31641 is similar to here. temporary solutionThere are already several solutions in the #27099 (comment) , Here are another solution: add these two files to our own project. These two files just copy the contents of Image and NetworkingHere are default handlers in I tested these two scenarios (use
Of course, if these original images conform to the apple png/jpeg image storage format, the size will not become larger. In addition.
related commits in historyf88bc3eb
this revision added file 36444a65
this revision deleted f78526ce
this revision added a solution e83feffe
this revision reverted FinallyIf there is something wrong with the above, feel free to tell me. 🙂 |
Not really as this is related to networking/images which is unrelated to the New Architecture at all |
this story is amazing.. A fix reverted for a dating app.. @ntdiary thanks for you solution, but I implemented it in a different way: here the patch: diff --git a/node_modules/react-native/Libraries/Network/RCTFileRequestHandler.mm b/node_modules/react-native/Libraries/Network/RCTFileRequestHandler.mm
index 19d025c..519c860 100644
--- a/node_modules/react-native/Libraries/Network/RCTFileRequestHandler.mm
+++ b/node_modules/react-native/Libraries/Network/RCTFileRequestHandler.mm
@@ -92,6 +92,22 @@ - (void)cancelRequest:(NSOperation *)op
return nullptr;
}
+/**
+ * Add this function to give precedence to the file upload instead of image upload. the image upload is changing the file
+ * with no reason.
+ * this handlerPriority is used only in the RCTNetworking.mm and this file is in defined in the network directory so I hope is not used
+ * else where
+ * for the bug see:
+ * https://github.com/facebook/react-native/issues/27099
+ * https://github.com/facebook/react-native/pull/31457
+ * https://github.com/facebook/react-native/commit/e83feffeba567b4e304181632128ee1caa036c45
+ * https://github.com/facebook/react-native/issues/33760
+*/
+- (float)handlerPriority
+{
+ return 3;
+}
+
@end
Class RCTFileRequestHandlerCls(void) |
I don't know why it was work, but I think maybe this can help guys. I have the same issue, but when I try to add the base64 into from to *I get these data by react-native-image-picker |
Thanks buddy - looks like it is working right now! :) |
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This issue was closed because it has been stalled for 7 days with no activity. |
This issue is not stale! We're still waiting for the fix that was backed out in e83feffe to be re-landed or replaced with a new fix. |
Reopening as we believe this is still an issue. Also related to: |
Description
When creating a
multipart/form-data
request with aFormData
object whose parts contain auri
property pointing to an image file, the resulting network request is much (~3-4 times) larger than the original image file.This issue only occurs on iOS. This is a duplicate of #27099, which has been closed but is not fixed.
Version
0.67.3
Output of
npx react-native info
Steps to reproduce
Obtain a URI to any on-disk image, call it
fileUri
.Create a
FormData
object with the file uri:Then, make a request with that form data:
Observe the content-length of the request headers if you control the server, or in this example, observe the response body from postman-echo.
Snack, code example, screenshot, or link to a repository
Snack demonstrating issue (and current workaround): https://snack.expo.dev/@httpriestess/image-upload-size-repro
It posts an image file to postman-echo, and then displays the content-length header that postman-echo returns.
The text was updated successfully, but these errors were encountered: