Skip to content
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

Fix for issue #749: RNFS.uploadFiles upload raw not multipart #759

Merged
merged 1 commit into from
Oct 4, 2019
Merged

Fix for issue #749: RNFS.uploadFiles upload raw not multipart #759

merged 1 commit into from
Oct 4, 2019

Conversation

scottewart
Copy link

The RCT_EXPORT_METHOD for uploadFiles was casting the config option of binaryStreamOnly to it's internal params. The option comes through as an NSNumber as with all boolean primitives via the RCT methods. In objective-c comparing a NSNumber to a BOOL directly will do a pointer comparison, meaning that it will always be true if anything is set (eg: 0, 1, 999, fizzbuzz, as long as it's an object, the pointer will be true). To fix this you need to use the boolValue method on NSNumber to return a BOOL that matches the original intent.

See: #749

The RCT_EXPORT_METHOD for uploadFiles was casting the config option of binaryStreamOnly to it's internal params. The option comes through as an NSNumber as with all boolean primitives via the RCT methods. In objective-c comparing a NSNumber to a BOOL directly will do a pointer comparison, meaning that it will always be true if anything is set (eg: 0, 1, 999, fizzbuzz, as long as it's an object, the pointer will be true). To fix this you need to use the boolValue method on NSNumber to return a BOOL that matches the original intent.
@scottewart
Copy link
Author

Hi @itinance, please take a look at my PR, it fixes a bug that only affects iOS multipart fileUploads.

@craftmusic
Copy link

👍 bless you, uploading files on ios was truly broken for me, the file upload request was indeed malformed due to this bug

This PR fixed the issue and my server is now able to detect the files as part of the request.

@itinance itinance merged commit 9d05150 into itinance:master Oct 4, 2019
@itinance
Copy link
Owner

itinance commented Oct 4, 2019

Thanks for this!

@scottewart
Copy link
Author

No problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants