Created
March 4, 2014 21:00
-
-
Save mgroves/9355523 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class BlobCloudService | |
| { | |
| readonly CloudBlobContainer _container; | |
| public BlobCloudService() | |
| { | |
| CloudStorageAccount storageAccount = CloudStorageAccount.Parse("your connection string"); | |
| CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); | |
| _container = blobClient.GetContainerReference("your container name"); | |
| } | |
| public bool DoesBlobExist(string blobName) | |
| { | |
| var blob = _container.GetBlockBlobReference(blobName); | |
| return blob.Exists(); | |
| } | |
| public CloudBlockBlob UploadBlob(string blobName, Stream inputStream) | |
| { | |
| CloudBlockBlob blobref = _container.GetBlockBlobReference(blobName); | |
| blobref.UploadFromStream(inputStream); | |
| return blobref; | |
| } | |
| public void DeleteBlob(string blobName) | |
| { | |
| var blob = _container.GetBlockBlobReference(blobName); | |
| blob.Delete(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment