如何直接从Blob返回图像? [英] How to Return Image Directly From Blob?

查看:164
本文介绍了如何直接从Blob返回图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数据库中有图像名称,没有下面的扩展名



数据库录入
------------ ---> Blob

1_1 -----------------------> 1_1.jpg

1_2 -----------------------> 1_2.png

1_3 -----------------------> 1_3.jpg

1_4 -----------------------> 1_4.png





在数据库中我没有图像扩展名。我想从blob中找到特定的图像。

下面是我的代码,它与每个图像比较1-1和1-1(blob从1-1.jpg删除扩展名)

匹配然后返回blob url。所以这很耗时。



我想使用带有comapare条件的Linq Query返回没有for循环返回的图像。

所以请给我关于这个问题的linq查询。



Plase帮助我达到性能目的。



以下是我的代码求助。



谢谢。

I have Image Name in Database without extension like below

Database Entry
---------------> Blob
1_1 -----------------------> 1_1.jpg
1_2 -----------------------> 1_2.png
1_3 -----------------------> 1_3.jpg
1_4 -----------------------> 1_4.png


In database I have no Image Extension. I want to find particular image from blob.
below is my code it compare with every image if 1-1 and 1-1(blob remove extension from 1-1.jpg)
match then return blob url. So it is time consuming.

I want to return image without for loop return using Linq Query with comapare condition.
so please give me linq query regarding this issue.

Plase help me for performance purpose.

Below is my code just for help.

Thanks.

public static string searchImageFromBlob(string intBLOBID, string strDataConnectionString, string strContainerName)
    {

     <   Microsoft.WindowsAzure.StorageClient.CloudBlobClient _BlobClient = null;
        var storageAccount = Microsoft.WindowsAzure.CloudStorageAccount.FromConfigurationSetting(strDataConnectionString);
        _BlobClient = storageAccount.CreateCloudBlobClient();

        Microsoft.WindowsAzure.StorageClient.CloudBlobContainer container = _BlobClient.GetContainerReference(strContainerName);
        if (container != null)
        {
            
            foreach (var properties in container.ListBlobs())
            {
                //litFeatureImage.Text = "";
                var blob = properties.Container.GetBlobReference(properties.Uri.ToString());
                if (intBLOBID == RemoveFileExtension(blob.Uri.Segments[2]))
                    return blob.Uri.ToString();

            }
        }


        return "";
    }

推荐答案

访问此处了解...



如何在Azure中使用Azure Blob存储网站 [ ^ ]
visit here to understand...

How to Use Azure Blob Storage with Azure Web Sites[^]


这篇关于如何直接从Blob返回图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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