use*_*168 2 c# containers blob azure
我正在尝试从Azure BlockBlob获取“内容类型”。好像不行。
如您所见,该文件的“内容类型”为“ image / jpeg”。
var cloudConn = System.Configuration.ConfigurationManager.ConnectionStrings["StoreAccount"].ConnectionString;
var storageAccount = CloudStorageAccount.Parse(cloudConn);
var blobClient = storageAccount.CreateCloudBlobClient();
var container = blobClient.GetContainerReference("containername");
var blocBlob = container.GetBlockBlobReference("009fc790-2e8e-4b59-bbae-3b5e2e845a3b");
Run Code Online (Sandbox Code Playgroud)
如该图所示,它总是返回空:
var blocBlob = container.GetBlockBlobReference("009fc790-2e8e-4b59-bbae-3b5e2e845a3b");
Run Code Online (Sandbox Code Playgroud)
Code above simply creates an instance of CloudBlockBlob
and initializes it with default properties. You would need to fetch the blob properties (as mentioned in the answer included in the comment above) and then you will see the properties filled up. To fetch blob properties, you would need to call FetchAttributes()
method.
var blocBlob = container.GetBlockBlobReference("009fc790-2e8e-4b59-bbae-3b5e2e845a3b");
blocBlob.FetchAttributes();
Run Code Online (Sandbox Code Playgroud)
Then you should be able to see the content type property of the blob.
要获取 blob 属性,您必须首先获取属性:
blob.FetchAttributes()
Run Code Online (Sandbox Code Playgroud)
然后您将能够通过以下方式获取内容类型:
blob.Properties.ContentType
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1919 次 |
最近记录: |