0

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);
    }
1
  • I got the answer for the question. container.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Container }); container.CreateIfNotExists(); Jun 3, 2016 at 6:10

1 Answer 1

0

I got the answer for the question. set the permission to public.T

container.SetPermissions(new BlobContainerPermissions { PublicAccess =         BlobContainerPublicAccessType.Container });
    container.CreateIfNotExists(); 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .