Here i am using Local azure storage emulator. I am able to store the images in the blob storage. I connected the azure storage emulator to my local DB, so i am able to see the local path of image in the data base. Here i need to get the path in the code and need to save in another table. here is the code. I need to return local image path.
public static CloudBlockBlob getAzureStorage(string imageName)
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("images");
container.CreateIfNotExists();
CloudBlockBlob blockBlob = container.GetBlockBlobReference(imageName);
return blockBlob;
}
public static string uploadToAzure(Image img, CloudBlockBlob blockBlob)
{
MemoryStream memoryStream = new MemoryStream();
img.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);
memoryStream.Position = 0;
blockBlob.UploadFromStream(memoryStream);
return String.Format("http://{0}{1}", blockBlob.Uri.DnsSafeHost, blockBlob.Uri.AbsolutePath);
}