O'Reilly logo

Play Framework Cookbook by Alexander Reelsen

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

Using MongoDB/GridFS to deliver files

MongoDB has a very nice feature called GridFS, which removes the need to store binary data in the filesystem. This example will feature a small (and completely unstyled) image gallery. The gallery allows you to upload a file and store it into MongoDB.

You can find the source code of this example in the chapter3/mongodb-image directory.

Getting ready

You should have installed the Morphia module in your application and should have a configured up-and-running MongoDB instance.

How to do it...

The application.conf file should feature a complete MongoDB configuration as for any Morphia-enabled application. Furthermore, a special parameter has been introduced, which represents the collection to store the binary data. ...

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