-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[馃悰] Storage putFile doesn't honor contentType metadata on iOS Simulator #5846
Comments
Hey, thanks for the thanks ;-), we really do try. I agree with you that you appear to have provided enough of the relevant details, at least for now, with the execution environment where you see these results - is it iOS Simulator going against storage emulator, or iOS real device against live storage etc. That could be informative Initial thoughts - really suspicious that this happened across versions here, since I know we haven't changed the storage code, examine how static this package has been since adding emulator support - just releases and version bumps for gradle really https://github.com/invertase/react-native-firebase/commits/main/packages/storage So what does change across releases? The firebase-ios-sdk version. v12.7.3 here was on firebase-ios-sdk 8.6.0 Are you maybe overriding the version like so: https://rnfirebase.io/#ios ? If you are not, then the most important first test here is, what happens when you override your version back to firebase-ios-sdk 8.6.0 - does it work again? If it does, what version stops working? I'm not able to find any issues upstream (yet) https://github.com/firebase/firebase-ios-sdk/issues?q=is%3Aissue+contentType so you might be first here I definitely remember while implementing storage emulator that it behaved incorrectly between firebase-ios-sdk and firebase storage emulator, specifically: react-native-firebase/packages/storage/e2e/StorageReference.e2e.js Lines 382 to 385 in d0d9bd8
It is still outstanding upstream: firebase/firebase-tools#3398 |
Oh now that you say it I remember that this is only an issue in the iOS simulator. However I don't use the storage emulator, so same issue against a live firebase environment. I just built a production build and there it works as expected. To answer your questions. It probably behaved exactly the same way in 12.7.3, but I compared with the prod build and that's why I thought it stopped working. No version overrides. So basically it boils down to an iOS simulator only issue :) |
Okay - I'm going to close this as upstream with no action here sadly, and rearrange the title just a little bit for future searchers, hopefully the upstream bug gets attention soon, I'll drop a ping on that as well. Good luck on your project! |
馃挴 % reasonable! Thanks for the triage |
@mikehardy I think this is a valid issue. |
@sneh-lio when I re-read the code you linked, what I read is that it is inside the completion handler for the firebase-ios-sdk storage module, that is, the contentType there is what is provided from firebase-ios-sdk as it calls back in to our code on completion. What do you see when you look at the firebase-ios-sdk code that executes, determines the contentType, and then provides that value as a parameter in the callback? |
@mikehardy The thing is when I specify contentType as "application/pdf" for a audio file then for Android it will be overwritten as a pdf file on storage bucket but for iOS it will be uploaded as the type detected by iOS sdk! |
Understood. How does it look inside firebase-ios-sdk? It's Open source, and the code there calls this completion handler, populating the variable I think. |
@mikehardy I checked the firebase-ios-sdk, in their implementation they don't overwrite the contentType provided in metadata but in the react-native-firebase/storage implemetation, contentType provided is overwritten by completion handler dishonouring the contentType provided by developer.
If you can confirm that I am correct, then I can create a PR! |
Thanks for persisting @sneh-lio - I think you are on to something here. I had more time and followed the callchain through, it appears that completion handler is not called from firebase-ios-sdk, that was an error in my mental model of how the control flow went. It appears that is just the internal method here in this module that does some pre-processing before it calls in to firebase-ios-sdk It appears that it attempts to get a mime type from the file here
Then on the line you posted originally, it is taking that value no matter what:
Then - the interesting part to me - the immediately following lines appear like they would take the provided metadata from the caller (your project code...) and use them if the metadata dictionary contentType weren't set already: react-native-firebase/packages/storage/ios/RNFBStorage/RNFBStorageModule.m Lines 434 to 437 in 924a829
...but of course because of line 432 just above, the metadata dictionary contentType is always set, so the project-specified contentType is never used. So yes! I think you have uncovered and correctly diagnosed an error and I think removing line 432 is safe. However, I think if the project-specific code does not provide a contentType, (so we enter the "content type is not set in the metadata dictionary" conditional) then rather than call the exact same method ( What do you think? If that sounds right and was what you were thinking, please do raise a PR! It would be most excellent if the relevant E2E storage tests were updated / extended to probe this case since it appears like an obvious error now that you've unmasked it, but the tests are currently passing and giving us a false positive https://github.com/invertase/react-native-firebase/blob/main/tests/README.md /
|
Hello 馃憢, to help manage issues we automatically close stale issues.
|
Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information. |
@mikehardy In my case, doing:
Uploads a broken file with correct mime type to Firebase Storage. This code worked good with Firebase JS SDK. If instead, I do the following, everything goes ok, but the mime type is "audio/x-m4a":
Then, I try with the new MIME type:
And the stored file is broken again. I am using @react-native-firebase/storage v18.1.0 |
Issue
When uploading a jpeg with...
...the uploaded file gets the wrong contentType. Trying to set the contentType explicitly with...
...is not working either.
This worked in
@react-native-firebase/storage@12.7.3
but not in13.0.1
.What do work is to upload as a base64 string with the contentType explicitly set:
I didn't provide any more details below as it doesn't seem relevant. But let me know and I'll provide more info.
Also want to take the opportunity to thank you for this massive library! Especially the speed and quality of each release. It makes me happy every time I use or upgrade it and really sets a standard in the react native community 馃檶
Project Files
Javascript
Click To Expand
package.json
:# N/A
firebase.json
for react-native-firebase v6:# N/A
iOS
Click To Expand
ios/Podfile
:# N/A
AppDelegate.m
:// N/A
Android
Click To Expand
Have you converted to AndroidX?
android/gradle.settings
jetifier=true
for Android compatibility?jetifier
for react-native compatibility?android/build.gradle
:// N/A
android/app/build.gradle
:// N/A
android/settings.gradle
:// N/A
MainApplication.java
:// N/A
AndroidManifest.xml
:<!-- N/A -->
Environment
Click To Expand
react-native info
output:react-native-firebase
version you're using that has this issue:e.g. 5.4.3
Firebase
module(s) you're using that has the issue:e.g. Instance ID
TypeScript
?Y/N
&VERSION
React Native Firebase
andInvertase
on Twitter for updates on the library.The text was updated successfully, but these errors were encountered: