'BSONDocument to byte array

I'm trying to post BSONDocument read from mongo to AWS Kinesis stream. However Kinesis API needs message as Byte array. Is there any way to covert BSONDocument(specifically reactivemongo.bson.BSONDocument) to byte array?



Solution 1:[1]

 MongoClient m = new MongoClient("mongodb://localhost:27017");
 var db = m.GetDatabase("TestDatabase");

 var collection = db.GetCollection<BsonDocument>("SomeCollection");

 // this will contain binary data (0s and 1s)
 var binaryData = collection.Find("{SomeProperty:true}").ToBson();

Hopefully this works I am not sure.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tono Nam