What is the best approach to store image into LiteDb?

Viewed 20

I want to add an image to some of the data I store in LiteDb (originally a png on the hard drive). With "some data" I mean more than one datatype in more than one collection.

Additional information: In the user interface (WPF) I use a BitmapImage.

For example I'm storing horses, riders and stables and for each horse, each rider and each stable I want to be able to store one (or none) image.

What would be a good approach?

I've read the documentation about FileStorage, so one approach might be to save the image as a file in FileStorage and reference it in my "normal" data. Is this a good way?

Another solution could be to convert the BitmapImage into a byte[] using a (Png)BitmapEncoder and store it directly in the data object. With this solution, I have concerns that I could exceed a limit in the database. I have found different documentation for this (e.g. LiteDB supports documents up to 16MB after BSON serialization and To keep its memory profile slim, LiteDB limits the size of a documents to 1MB.)

0 Answers
Related