me.at.coding
me.at.coding

Reputation: 17654

Get URI of uploaded blob?

Consider the following code:

// _blobContainerClient is an instance of BlobContainerClient
await _blobContainerClient.UploadBlobAsync(uniqueName, stream);

string uri = < how to get the URI? >

How do I get the URI of the uploaded blob?

I am using Azure.Storage.Blobs 12.8.0.

Upvotes: 3

Views: 2774

Answers (2)

Sajeetharan
Sajeetharan

Reputation: 222582

You just need to create a client and return the Uri this,

var blob = new BlobClient(connectionString, containerName, fileName);
await blob.UploadAsync(fileStream, o);
return ReturnUri(blob.Uri);

Upvotes: 6

silent
silent

Reputation: 16138

If you want to do more things with the blob object, I would recommend creating a new BlobClient. If you just need the URI this should work as well:

var blobUri = $"{_blobContainerClient.Uri.AbsoluteUri}/{uniqueName}";

Upvotes: 2

Related Questions