Azure DocumentDB的MongoAPI中的GridFS支持 [英] GridFS support in MongoAPI of Azure DocumentDB

查看:76
本文介绍了Azure DocumentDB的MongoAPI中的GridFS支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过JAVA中的springdata通过GridFsTemplate使用MongoDB API for DocumentDB.

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

尝试使用MongoDB的GridFS部分管理大型文件时出现错误.

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"
}

我在使用Robomongo并尝试检查fs.chunks集合时遇到了相同的错误.

I get the same error using Robomongo and trying to inspect the fs.chunks collection.

之所以说可以创建集合,是因为使用Azure的Web界面中的浏览"功能,似乎fs.chunks只有一条记录,而不是很多记录.所以也许存储是个问题.

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.

如果使用标准的MongoDB,所有这些都可以正常工作.

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

推荐答案

存在第三方 Azure Cosmos DB ,它是一种多模型数据库,其中包括文档,键值,图形,而不是BLOB.因此,我认为您应该只考虑使用

There is a third party 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 as a JSON store system. If you want to use storage for files, please consider for Azure Blob storage.

希望有帮助.

这篇关于Azure DocumentDB的MongoAPI中的GridFS支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆