azure-cosmosdb - Azure DocumentDB 的 MongoAPI 中的 GridFS 支持

标签 azure-cosmosdb gridfs

我正在通过 JAVA 中 springdata 的 GridFsTemplate 将 MongoDB API 用于 DocumentDB。

尝试使用 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介绍DocumentDB和MongoDB的区别,请注意Binary Large Object (BLOB) Storage部分.现在,Azure DocumentDB 已扩展和升级为 Azure Cosmos DB这是多模型数据库,包括文档、键值、图形,而不是 BLOB。所以我认为你应该只考虑使用 DocumentDBCosmos DB via MongoDB API作为 JSON 存储系统。如果要使用文件存储,请考虑使用 Azure Blob 存储。

希望能帮助到你。

关于azure-cosmosdb - Azure DocumentDB 的 MongoAPI 中的 GridFS 支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43901158/

相关文章:

java - Cosmos DB 异步客户端 : Iterator<FeedResponse<Document>> it is getting stuck on hasNext() method

javascript - Cosmos DB 查询可以在 Data Explorer 中运行,但不能在 Node.js 中运行

Azure函数: how to bind query string parameters of http trigger function to SQL query of Cosmos DB

javascript - 用meteor将图片存入数据库好不好?

Node.js 通过 REST API 发送图像

java - 使用 GridFSOperations 获取所有文档

azure - 如何构建 DocumentDB 数据库

python - 宇宙数据库 : Unable to run group by query in python SDK

带有可插拔 MongoDB 存储问题的 Django

javascript - 保存使用 GridFS 下载的文件以在网站上使用