google / googleapis.dart

Repository for building the googleapis packages
https://pub.dev/packages/googleapis
BSD 3-Clause "New" or "Revised" License
393 stars 118 forks source link

Bug in discovery api multipart stream encoder handling #636

Closed Mereep closed 2 months ago

Mereep commented 2 months ago

In multipart_media_uploader.dart there seems to be a missue with the stream handling API

  await bodyController.addStream(
          _uploadMedia.stream
              .transform(_base64Encoder)
              .transform(ascii.encoder),
        );

https://github.com/google/googleapis.dart/blob/f5dceee24ea1ed7ff5943fa9ccead4e8ebe4bfe5/discoveryapis_commons/lib/src/multipart_media_uploader.dart#L57C7-L61C11

with

https://github.com/google/googleapis.dart/blob/f5dceee24ea1ed7ff5943fa9ccead4e8ebe4bfe5/discoveryapis_commons/lib/src/multipart_media_uploader.dart#L18

will result in an annoying runtime type error like type 'Base64Encoder' is not a subtype of type 'StreamTransformer<Uint8List, String>' of 'streamTransformer'

after a bit of Google I found an API change related to this problem: https://groups.google.com/g/flutter-dev/c/zKWTAMJTvos

For me, it could be fixed by replacing with

 await bodyController.addStream(
          _base64Encoder.bind(_uploadMedia.stream)
              .transform(ascii.encoder),
        );
kevmoo commented 2 months ago

will investigate!

kevmoo commented 2 months ago

Yep. Need to handle when the stream controller is a Uint8List