Skip to content

Instantly share code, notes, and snippets.

@cchitsiang
Forked from lilith/upload-to-azure.cs
Last active September 19, 2015 04:44
Show Gist options
  • Save cchitsiang/cbc8fd4c1545b5f83703 to your computer and use it in GitHub Desktop.
Save cchitsiang/cbc8fd4c1545b5f83703 to your computer and use it in GitHub Desktop.

Revisions

  1. @lilith lilith revised this gist Apr 18, 2013. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions upload-to-azure.cs
    Original file line number Diff line number Diff line change
    @@ -15,4 +15,6 @@

    ImageBuilder.Current.Build("~/originalFile.jpg", ms, new ResizeSettings("width=3200&height=3200&format=jpg"));

    ms.Seek(0,SeekOrigin.Begin);

    blockBlob.UploadFromStream(ms);
  2. @lilith lilith created this gist Apr 15, 2013.
    18 changes: 18 additions & 0 deletions upload-to-azure.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    // Retrieve storage account from connection string.
    CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
    CloudConfigurationManager.GetSetting("StorageConnectionString"));

    // Create the blob client.
    CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

    // Retrieve reference to a previously created container.
    CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");

    // Retrieve reference to a blob named "myblob".
    CloudBlockBlob blockBlob = container.GetBlockBlobReference("newfile.jpg");

    var ms = new MemoryStream();

    ImageBuilder.Current.Build("~/originalFile.jpg", ms, new ResizeSettings("width=3200&height=3200&format=jpg"));

    blockBlob.UploadFromStream(ms);