GridFS support in MongoAPI Azure DocumentDB

I am using MongoDB API for DocumentDB via GridFsTemplate from springdata to JAVA.

I am getting an error while trying to use the GridFS part of MongoDB to manage large files.

I can create a file (I think) and find its metadata, but I cannot get the contents of the file. When doing so, 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 am getting the same error using Robomongo and trying to check the fs.chunks collection.

The reason I say that I can create a collection is because using the Browse feature in the Azure web interface, fs.chunks seems to have only one entry instead of many chunks. Therefore, there may be a storage problem.

This all works great when using standard MongoDB.

This is the code to save the file, which exits without error.

gridFsTemplate.store( content, filename, contentType, metadata );

      

And here is the code to find it and get the content

//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 );
}

      

+3


source to share


1 answer


There is a third party blog that introduces the differences between DocumentDB and MongoDB, take a look at the section Binary Large Object (BLOB) Storage

. And now Azure DocumentDB has been extended and updated as Azure Cosmos DB , which is a multi-model database that includes document, key value, graph, not BLOB. So I think you should only consider DocumentDB or Space DB via MongoDB API as JSON storage system. If you want to use file storage, take a look at Azure Blob storage.



Hope it helps.

+1


source







All Articles