O'Reilly logo

MongoDB Cookbook - Second Edition by Amol Nayak, Cyrus Dasadia

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Storing data to GridFS from Java client

In the previous recipe, we saw how to store data to GridFS using a command-line utility that comes with MongoDB to manage large data files: mongofiles. To get an idea of what GridFS is and what collections are used behind the scenes to store the data, refer to the previous recipe Storing large data in Mongo using GridFS.

In this recipe, we will look at storing data to GridFS using a Java client. The program will be a highly scaled down version of mongofiles utility and focus only on how to store, retrieve, and delete data rather than trying to provide a lot of options like mongofiles do.

Getting ready

Refer to the recipe Installing single node MongoDB from Chapter 1, Installing and Starting the Server, for ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required