:

Java MongoDB : Save image example

心已入冬 提交于 2019-11-28 10:39:20
Java MongoDB : Save image example In this tutorial, we show you how to save an image file into MongoDB, via GridFS API . The GridFS APIs are able to serve other binary files as well, like video and music files. 译:在本教程中,我们将向你展示如何通过 GridFS API 保存一个图片到MongoDB。 GridFS APIs 提供将其他二进制文件的支持,比如视频和音频等。 Note For detail explanation, read this MongoDB GridFS manual . 译:详细解释,请阅读 MongoDB GridFS 文档 . 1. Save image Code snippets to save an image file into MongoDB, under “photo” namespace, and assign a new “filename” for the saved image. 译:下面代码片断为保存一个图片文件到MongoDB,在"photo"命名空间下,将图片文件取一个新名保存。 Java代码 String