title: What is the best strategy to upload large file using HttpClient in a low memory windows phone device?
body: <p>I am trying to upload files using similar approach <a href="https://stackoverflow.com/questions/16906711/httpclient-how-to-upload-multiple-files-at-once]">HttpClient: How to upload multiple files at once</a>
   in windows phone.</p>
  
  <pre><code>using (var content = new MultipartFormDataContent())
  {
      content.Add(CreateFileContent(imageStream, "image.jpg", "image/jpeg"));
      content.Add(CreateFileContent(signatureStream, "image.jpg.sig", "application/octet-stream"));
  
      var response = await httpClient.PostAsync(_profileImageUploadUri, content);
      response.EnsureSuccessStatusCode();
  }
  
  private StreamContent CreateFileContent(Stream stream, string fileName, string contentType)
  {
      var fileContent = new StreamContent(stream);
      fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data") 
      { 
          Name = "\"files\"", 
          FileName = "\"" + fileName + "\""
      }; // the extra quotes are key here
      fileContent.Headers.ContentType = new MediaTypeHeaderValue(contentType);            
      return fileContent;
  }
  </code></pre>
  
  <p>This works fine while uploading small files. If I tried to upload larger file(say > 50mb) in a low end device(512Mb memory),
  it throws System.OutOfMemoryException. I used the diagnostic tools to monitor the memory consumption and noticed that memory 
  grows exponentially during PostAsync call. Seems like it is copying  the entire content to the memory. Right now we don't have chunking support in the
  api. </p>
  
  <p>What is the best strategy to upload large file using HttpClient in a low memory windows phone device?</p>