Azure Cosmos DB-如何存储带有标签的图像 [英] Azure Cosmos DB - how to store images with tags
问题描述
想要将带有一些标签/文字的图像存储在Azure Cosmos DB中,例如老人",踢足球的人",吃狗的狗"等.
Want to store the images with some tags/text utterances like 'old man', 'man playing soccer' , 'dog eating food' etc in Azure Cosmos DB.
1.在Azure门户中从"SQL","MongoDB","Cassandra"和"Azure Table"中创建数据库时,应使用哪种API来存储图像.
1. Which API should be used while creating DB in Azure portal out of 'SQL', 'MongoDB', 'Cassandra' and 'Azure Table' for storing images.
2.创建数据库之后,如何以编程方式存储带有标签的图像.
2. After creating the DB, how to store images with tags programmatically .
推荐答案
Abhishek,
Hi Abhishek,
Please take a look at the following Stack Overflow thread: How can I store Images in Azure Cosmos DB ?
有两种不同的方法可以实现这一目的.
There are a couple different methods for accomplishing this.
- 使用指向存储在Azure Blob存储(SQL或Table API)上的物理图像文件的链接将元数据存储在Cosmos DB中.
- 使用表将元数据和图像文件存储在Cosmos DB中API.
我希望这能回答您的问题.
I hope this answers your question.
以下代码示例用于使用 DocumentClient.CreateAttachmentAsync
The following code example is for storing the image file in Cosmos DB with DocumentClient.CreateAttachmentAsync
using (FileStream fileStream = new FileStream(@".\something.pdf", FileMode.Open))
{
//Create the attachment
Attachment attachment = await client.CreateAttachmentAsync("dbs/db_rid/colls/coll_rid/docs/doc_rid/attachments/",
fileStream,
new MediaOptions
{
ContentType = "image/jpeg",
Slug = "myImage.jpeg"
});
}
此致
迈克
这篇关于Azure Cosmos DB-如何存储带有标签的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!