Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,


Can anyone please suggest me how to store data in Blob Storage of Windows Azure?

Please provide a simple demo which is easy to understand.

Thanks in Advance.
Posted

 
Share this answer
 
Comments
Espen Harlinn 12-Jun-12 8:18am    
5'ed!
following is the code for stroing the data in Windows Azure Blobs
CloudStorageAccount caccount = CloudStorageAccount.Parse("enter your connection string");

               CloudBlobClient cbclient = caccount.CreateCloudBlobClient();
               //creating container
               CloudBlobContainer cbcontainer = cbclient.GetContainerReference("mycontainer");
               cbcontainer.CreateIfNotExist();

               BlobContainerPermissions permission = new BlobContainerPermissions();
               permission.PublicAccess = BlobContainerPublicAccessType.Blob;
               cbcontainer.SetPermissions(permission);


               string fname = Path.GetFileName(FileUpload1.FileName);

               CloudBlob blob = cbcontainer.GetBlobReference(Guid.NewGuid().ToString() + fname);

               blob.UploadFromStream(FileUpload1.FileContent);
               string url = blob.Uri.ToString();
 
Share this answer
 
Comments
Espen Harlinn 12-Jun-12 8:18am    
5'ed!
k.Prathap 12-Jun-12 8:21am    
thank you. is my solution is helpful for your project?
[no name] 13-Jun-12 8:55am    
thanks....great.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900