title: Azure Blob Storage - Uploading Http/StreamContent to a CloudBlockBlob from WebApi Controller
body: <p>I am sending a PDF file to my WebAPI Controller via a POST request using Angular as such:</p>
  
  <pre><code>  $scope.upload = Upload.upload({
          url: "../api/Locker/Upload", // webapi url
          method: "POST",
          file: controllerFile,
    })
  </code></pre>
  
  <p>which in my POST method on my controller I get the StreamContent of that file as follows: </p>
  
  <pre><code> public async Task&lt;HttpResponseMessage&gt; Post()
      {
          HttpRequestMessage request = this.Request;
          if (!request.Content.IsMimeMultipartContent())
          {
              request.CreateResponse(HttpStatusCode.UnsupportedMediaType);
          }
  
          var result = await Request.Content.ReadAsMultipartAsync&lt;CustomMultipartFormDataProvider&gt;(new CustomMultipartFormDataProvider());
  
          string fileName = result.FileData[0].Headers.ContentDisposition.FileName;
          var fileData = result.Contents[0]; 
  
   }
  </code></pre>
  
  <p>It is saying that results.Contents[0] is of type HttpContent but in the Immediate window when I type fileData it says it is of StreamContent type. </p>
  
  <p>I am trying to upload to Azure Blob Storage this fileData so that I can then retrieve it using a GET request later on, but am having trouble doing so. </p>
  
  <pre><code>    //in post method
      CloudStorageAccount storageAccount = CloudStorageAccount.Parse(blobConnectionString);
      CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
      CloudBlobContainer container = blobClient.GetContainerReference(blobContainer);
      await container.CreateIfNotExistsAsync();
  
      string blobId = Guid.NewGuid().ToString();
  
      UploadToBlob(container, blobId, fileData);
  </code></pre>
  
  <p>and method where I am stuck:</p>
  
  <pre><code>  private async void UploadToBlob(CloudBlobContainer container, string blobId, HttpContent fileData)
      {
          CloudBlockBlob block = container.GetBlockBlobReference(blobId);
          block.UploadFromStream(fileData);
      }
  </code></pre>
  
  <p>error on block.UploadFromStream because fileData is not a Stream of course.</p>
  
  <p>What can I do if I am expecting a HTTP Response with content being of type: arraybuffer so that I can expose the file in my web application such as:</p>
  
  <pre><code>  //angular get request
   .success(function (data, status, headers, config) {
          // file is uploaded successfully
          console.log(data);
  
          var fileBack = new Blob([(data)], { type: 'application/pdf' });
          var fileURL = URL.createObjectURL(fileBack);
   }
  </code></pre>