-
Notifications
You must be signed in to change notification settings - Fork 4k
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
[firebase_storage] Updating storage metadata replaces all existing metadata #2307
Comments
A quick fix could be:
|
Hi @puf |
Hey Taha, The problem seems to exist in the latest code (linked above). The minimal code is in the steps-to-reproduce above, and in the Stack Overflow issue I linked.
|
Will get this checked out & tested. |
I've tested this on the latest roadmap version and confirm that the First Call
Second Call
|
Thanks for the update Greg. Let me know once this makes it into a regular release, so I can update my answer on Stack Overflow. |
Took a while to get back to this issue sorry but this has been in stable for over a month now so this is ok to be closed now. Thanks again for the report @puf 🎉 |
Describe the bug
According to the Firebase documentation you can update storage metadata via the
updateMetadata
API.The FlutterFire documentation for the same API mimics this by:
This is not how it works in practice though: calling
updateMetadata
replaces all metadata with the information provided in the call.To Reproduce
See https://stackoverflow.com/q/61051148
Steps to reproduce the behavior:
StorageReference
to a file that has metadata, for example: a content type.storageReference.updateMetadata(StorageMetadata(customMetadata: {'receiver': 'ID'}));
Expected behavior
Above call should leave the existing metadata unmodified.
Additional context
As far as I can see the problem comes from
_buildMetadataUploadMap
, which doesn't seem to handle missing properties correctly. Callingprint(_buildMetadataUploadMap(StorageMetadata(customMetadata: {'receiver': 'ID2'})))
prints:I'm pretty sure this map should only contain
customMetadata
in this case.The text was updated successfully, but these errors were encountered: