简体   繁体   English

如何将图像文件存储在 Azure Cosmos DB 中?

[英]How to store image files in Azure Cosmos DB?

I am trying to upload images to azure cosmos DB but can't find any documentation.我正在尝试将图像上传到 azure cosmos DB,但找不到任何文档。

We are using the new version of cosmos DB library:我们正在使用新版本的 cosmos DB 库:

implementation 'com.azure:azure-cosmos:3.1.0'

I found AsyncDocumentClient from com.microsoft.azure.cosmosdb.rx package which has我从 com.microsoft.azure.cosmosdb.rx package 找到了 AsyncDocumentClient

public Observable<>> createAttachment(String documentLink, Attachment attachment, RequestOptions options)

public Observable<>> createAttachment(String documentLink, InputStream mediaStream, MediaOptions options, RequestOptions requestOptions)


but this library( java Async SDK v2 ) has been deprecated and replaced with the new SDK( Java Sdk v4 ). but this library( java Async SDK v2 ) has been deprecated and replaced with the new SDK( Java Sdk v4 ). I cant find anything regarding managed attachments in the new SDK.我在新的 SDK 中找不到任何有关托管附件的信息。 What options do we have to upload the files now?我们现在有哪些选项可以上传文件?

PS. PS。 I know we should use blob storage from azure, but we don't have it right now我知道我们应该使用 azure 中的 blob 存储,但我们现在没有

You really should move to blob storage, attachments are obsolete as stated in the docs :您真的应该转移到 blob 存储,附件已过时,如文档中所述

Attachment is a legacy feature.附件是一项遗留功能。 Their support is scoped to offer continued functionality if you are already using this feature.如果您已经在使用此功能,他们的支持范围可提供持续的功能。

Instead of using attachments, we recommend you to use Azure Blob Storage as a purpose-built blob storage service to store blob data.我们建议您不要使用附件,而是使用 Azure Blob 存储作为专门构建的 Blob 存储服务来存储 Blob 数据。 You can continue to store metadata related to blobs, along with reference URI links, in Azure Cosmos DB as item properties.您可以继续将与 blob 相关的元数据以及参考 URI 链接存储在 Azure Cosmos DB 中作为项目属性。 Storing this data in Azure Cosmos DB provides the ability to query metadata and links to blobs stored in Azure Blob Storage.将此数据存储在 Azure Cosmos DB 中提供了查询元数据和指向存储在 Azure Blob 存储中的 blob 的链接的能力。

That is why you won't find it in newer SDKs.这就是为什么您不会在较新的 SDK 中找到它的原因。 So either stick to an older library (not recommended) or move to the new approach.因此,要么坚持使用较旧的库(不推荐),要么转向新方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM