Closed paulreimer closed 5 years ago
The ‘write’ method is supposed to only write string values. Everything that is not a ‘String’, gets converted with ‘toString()’ call. This contract comes from the Dart’s IOSink class, actually, node_io simply tries to follow it. Docs: https://api.dartlang.org/dev/2.0.0-dev.63.0/dart-io/IOSink/write.html
To add byte data there is ‘add’ method.
Hope this helps.
Oh, the first example shouldn’t work either. This is strange since firebase functions use the same node_io implementation.
Well, oddly the first example does work! Maybe the Buffer.from(...)
is affecting things? But using add
also works in both cases (so it does resolve this issue for me!).
In fact I no longer need the package:node_interop:buffer.dart
dependency and I can add
my Uint8List bytes directly.
Thanks so much for the help!
Glad it works for you now.
Wondering if you can provide a more complete version of the first example? Would be nice to figure out what's going on there.
This works with
node_interop
and Google Cloud Function (binary data is returned in the response):But with
firebase-functions-interop
it returns the toString representation of aList<int>
of the binary data:Produces the output: