Reactive Scala Driver for MongoDB
Asynchronous & Non-Blocking
GridFS is a way to store and retrieve files using MongoDB.
ReactiveMongo provides an API for MongoDB GridFS, whose references can be resolved as bellow.
Save files to GridFS
Once a reference to GridFS is obtained, it can be used to push a file in a streaming way (for now using Play Iteratees).
save operation will return a reference to the stored object, represented with the
An alternative operation
saveWithMD5, which can automatically compute a MD5 checksum for the stored data.
The reference for a file save in this way will have
Some MD5 property.
Find a file from GridFS
A file previously stored in a GridFS can be retrieved as any MongoDB, using a
Delete a file
A file can be removed from a GridFS using the appropriate operation.
For the GridFS
save operation, the following compilation error can be raised when the required
Reader is missing.
could not find implicit value for parameter readFileReader: gfs.pack.Reader[gfs.ReadFile[reactivemongo.bson.BSONValue]]
It can be easily fixed by adding the appropriate import:
A similar compilation error can occur for the
could not find implicit value for parameter readFileReader: gridfs.pack.Reader[T]
It’s fixed by the same import.