Azure DocumentDB 的 MongoAPI 中的 GridFS 支持
GridFS support in MongoAPI of Azure DocumentDB
我在 JAVA.
中通过来自 springdata 的 GridFsTemplate 为 DocumentDB 使用 MongoDB API
我在尝试使用 MongoDB 的 GridFS 部分管理大文件时遇到错误。
我能够创建一个文件(我认为)并找到它的元数据,但我无法检索文件内容。返回以下错误:
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"
}
我在使用 Robomongo 并尝试检查 fs.chunks 集合时遇到同样的错误。
之所以说我认为我可以创建集合是因为使用 Azure 的 Web 界面中的浏览功能,fs.chunks 似乎只有一条记录而不是许多块。所以也许存储是问题所在。
如果使用标准 MongoDB,所有这些都可以正常工作。
这是保存文件的代码,它没有错误地完成。
gridFsTemplate.store( content, filename, contentType, metadata );
这是找到它并获取内容的代码
//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 );
}
有第三方 blog which introduce the differences between DocumentDB and MongoDB, please note the section Binary Large Object (BLOB) Storage
. And now, Azure DocumentDB has been extended & upgraded as Azure Cosmos DB which is multi-model database which includes document, key-value, graph, not BLOB. So I think you should only consider to use DocumentDB or Cosmos DB via MongoDB API 作为 JSON 商店系统。如果要使用文件存储,请考虑使用 Azure Blob 存储。
希望对您有所帮助。
我在 JAVA.
中通过来自 springdata 的 GridFsTemplate 为 DocumentDB 使用 MongoDB API我在尝试使用 MongoDB 的 GridFS 部分管理大文件时遇到错误。
我能够创建一个文件(我认为)并找到它的元数据,但我无法检索文件内容。返回以下错误:
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"
}
我在使用 Robomongo 并尝试检查 fs.chunks 集合时遇到同样的错误。
之所以说我认为我可以创建集合是因为使用 Azure 的 Web 界面中的浏览功能,fs.chunks 似乎只有一条记录而不是许多块。所以也许存储是问题所在。
如果使用标准 MongoDB,所有这些都可以正常工作。
这是保存文件的代码,它没有错误地完成。
gridFsTemplate.store( content, filename, contentType, metadata );
这是找到它并获取内容的代码
//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 );
}
有第三方 blog which introduce the differences between DocumentDB and MongoDB, please note the section Binary Large Object (BLOB) Storage
. And now, Azure DocumentDB has been extended & upgraded as Azure Cosmos DB which is multi-model database which includes document, key-value, graph, not BLOB. So I think you should only consider to use DocumentDB or Cosmos DB via MongoDB API 作为 JSON 商店系统。如果要使用文件存储,请考虑使用 Azure Blob 存储。
希望对您有所帮助。