how to get blob-URL after file upload in azure

让人想犯罪 __ 提交于 2019-12-03 09:24:36
Gaurav Mantri

Assuming you're uploading the blobs into blob storage using .Net storage client library by creating an instance of CloudBlockBlob, you can get the URL of the blob by reading Uri property of the blob.

static void BlobUrl()
{
    var account = new CloudStorageAccount(new StorageCredentials(accountName, accountKey), true);
    var cloudBlobClient = account.CreateCloudBlobClient();
    var container = cloudBlobClient.GetContainerReference("container-name");
    var blob = container.GetBlockBlobReference("image.png");
    blob.UploadFromFile("File Path ....");//Upload file....

    var blobUrl = blob.Uri.AbsoluteUri;
}

View example on Pastebin

The above solution is perfect you just have to add the below code to get the url of Image.

static void BlobUrl()
{
var account = new CloudStorageAccount(new StorageCredentials(accountName, accountKey), true);
var cloudBlobClient = account.CreateCloudBlobClient();
var container = cloudBlobClient.GetContainerReference("container-name");
var blob = container.GetBlockBlobReference("image.png");
blob.UploadFromFile("File Path ....");//Upload file....

string blobUrl = blob.Uri.AbsoluteUri;
}

This string -> blobUrl will give you the url of blob to get the image.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!