firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.44k stars 3.91k forks source link

fix(storage, windows): putFile(), putString(), putData() & Task streaming event fixes #12723

Closed russellwheatley closed 1 week ago

russellwheatley commented 2 weeks ago

Description

Fixes

  1. putData() is now writing the data as intended.
  2. putString() is now decoding from base64 and base64Url before writing string (previously writing string as base64).
  3. putFile() metadata was not working correctly.
  4. putFile() we have also had to do a hack to pass metadata as null on windows, it was throwing exception in pigeon even though it is allowable as a nullable value. Not ideal, but it works.
  5. customMetadata is now returned with the snapshot which fixes: https://github.com/firebase/flutterfire/issues/12711
  6. Some responses were coming back completely incorrect, they have been fixed by using EncodableValue() to pass values back to Flutter.
  7. task!.snapshotEvents events were never firing. The storage event listener (onProgress, and onPause) were incorrectly passed to the API handler (e.g. putBytes(), putFile(), etc). This is the correct way to instantiate.
  8. task.pause(), task.cancel(), task.resume() were also broken. The incorrect encoding of values passed back to Flutter stopped the flutter side from having proper values to parse.
  9. The error map was never passed back in the stream event handling so exception were not being thrown correctly when listening to events.
  10. Fixed an issue in Firebase core C++ were AppOptions (equivalent to FirebaseOptions in Flutter side) was creating every property as an empty string. For example, storage bucket option was being passed back to Flutter as an empty string.
  11. snapshot was missing path property causing exception on Flutter side when handling File streaming events.
  12. metadata as a property on snapshot was also missing bucket property.

Tests

  1. Storage windows now has integration tests albeit using a live Firebase project. There are some tests that are skipped which are largely stream handling events, I spent quite a bit of time on this. It works when running the app but fails in a test environment. The good news is most tests are being used.
  2. I updated the putData(), putFile() and putString() tests to also check the content is correct and not gibberish or base64 encoding.
  3. I've found a bug in the C++ SDK, if you try to update metadata on an object that does not exist, it will throw an unauthorized exception rather than an object-not-found exception. I checked native, it is a firebase SDK bug.

Related Issues

fixes https://github.com/firebase/flutterfire/issues/12743 fixes https://github.com/firebase/flutterfire/issues/12711

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?