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 ...
Get MongoDB Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.