显示图像作为ravendb附件检索

时间:2013-11-12 10:28:14

标签: c# .net winforms ravendb

简单问题:如何在winforms pictureBox中显示检索到的ravendb附件图像。

附件被检索为

Raven.Abstractions.Data.Attachment attachment =
                        _store.DatabaseCommands.GetAttachment("upload/"+ 9999);

更新

使用像这样的附件保存图像

 _Store.DatabaseCommands.PutAttachment("upload/" + attachId, null, ms,
                                            new RavenJObject
                                                {
                                                   { "Content-Type", "image/jpeg" }

                                                });

ms是内存流

1 个答案:

答案 0 :(得分:2)

您需要从Attachment对象中检索附件内存流:

pictureBox1.Image = Image.FromStream(attachment.Data());

the docs

中查看详情