I am using the MongoDB API for DocumentDB via the GridFsTemplate from springdata in JAVA.
I am getting an error when trying to use the GridFS part of MongoDB to manage large files.
I am able to create a file (I think) and find its metadata, but I cannot retrieve the file contents. The following error is returned:
Error: error: {
"_t" : "OKMongoResponse",
"ok" : 0,
"code" : 8,
"errmsg" : "The value '/media/7hsUAJOI2QsBAAAAAAAAAEeWwrcB' specified for query '$resolveFor' is invalid.\r\nActivityId: a68945e8-0000-0000-0000-000000000000",
"$err" : "The value '/media/7hsUAJOI2QsBAAAAAAAAAEeWwrcB' specified for query '$resolveFor' is invalid.\r\nActivityId: a68945e8-0000-0000-0000-000000000000"
}
I get the same error using Robomongo and trying to inspect the fs.chunks collection.
The reason I say that I think I can create the collection is because using the Browse functionality in Azure's web interface, it seems that fs.chunks has only one record instead of many chunks. So maybe the storing is the issue.
All of this works fine if using the standard MongoDB.
This is the code to save the file which completes without error.
gridFsTemplate.store( content, filename, contentType, metadata );
And here is the code to find it and get the contents
//this works
GridFSDBFile data = gridFsTemplate.findOne( query );
ByteArrayOutputStream out = new ByteArrayOutputStream();
if ( data != null )
{
//this results in Exception with the same message as the error above
data.writeTo( out );
}