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?
Asked
Active
Viewed 2,016 times
4
-
**EDIT** reactivemongo.bson.BSONDocument object has write method that writes to different types of buffer. val buffer = new ArrayBSONBuffer() BSONDocument.write(doc, buffer) val data = buffer.array – Hiren Oct 13 '15 at 20:32
1 Answers
0
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.

Tono Nam
- 34,064
- 78
- 298
- 470