title: POST a single large file in .net core
body: <p>I have a .net core 2.1 api application that will download a file from a remote location based on the file name.  Here is the code:</p>
  
  <pre><code>static public class FileDownloadAsync
  {
      static public async Task DownloadFile(string filename)
      {
          //File name is 1GB.zip for testing
          Stopwatch stopwatch = new Stopwatch();
          stopwatch.Start();
          using (HttpClient client = new HttpClient())
          {
              string url = @"http://speedtest.tele2.net/" + filename;
              using (HttpResponseMessage response = await client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead))
              using (Stream readFrom = await response.Content.ReadAsStreamAsync())
              {
                  string tempFile = $"D:\\Test\\{filename}";
                  using (Stream writeTo = File.Open(tempFile, FileMode.Create))
                  {
                      await readFrom.CopyToAsync(writeTo);
                  }
              }
              stopwatch.Stop();
              Debug.Print(stopwatch.Elapsed.ToString());
          }
      }
  }
  </code></pre>
  
  <p>This is working great, it will pull a 1 gig file down in about 50 seconds.  Well within the required download time.  I have hard coded a test file to download in this code for testing as well as storage location--these values will ultimately come from a config file when moved into production.  Here is the API endpoint that calls this function:</p>
  
  <pre><code> [HttpGet("{fileName}")]
      public async Task&lt;string&gt; GetFile(string fileName)
      {
  
          await FileDownloadAsync.DownloadFile(fileName);
          return "Done";
      }
  </code></pre>
  
  <p>So getting the file from a remote location down to the local server is not a problem.  I need some help/guidance on re-posting this file to another API.  Once the file is downloaded, there is some work done on the file to prepare it for upload (the files are all MP4 files), and once that work is done, I need to post it to another API for more proprietary processing.  Here is the API end point data I have:</p>
  
  <blockquote>
    <p>POST: /batch/requests Allocates resources to start new batch transcription. Use this method to request[work] on the input
    audio data. Upon the accepted request, the response provides
    information about the associated request ID and processing status.</p>
    
    <p>Headers: Authorization: Authorization token</p>
    
    <p>Accept: application/json</p>
    
    <p>Content-Type: Indicates the audio format. The value must be:
    audio/x-wav;codec=pcm;bit=16;rate=8000;channels=1
    audio/x-wav;codec=pcm;bit=16;rate=16000;channels=1
    audio/x-raw;codec=pcm;bit=16;rate=8000;channels=1
    audio/x-raw;codec=pcm;bit=16;rate=16000;channels=1 </p>
    
    <p>video/mp4</p>
    
    <p>Content-Length (optional): The size of the input voice file. <strong>Not
    required if a chunked transfer is used.</strong></p>
    
    <p>Query string parameters (required):</p>
    
    <p>profileId: one of supported (see GET profiles) customerId: the id of
    the customer. A string of minimum 1 and up to 250 alphanumeric, dot
    (.) and dash (-) characters.</p>
  </blockquote>
  
  <p>So I will set the Content-Type to video/MP4 for processing.  Note that if the input size is not used if a chunked transfer is used.  </p>
  
  <p>Right now, I am more concerned with just posting (streaming) the file in a non-chunked format while we await for more information on what they consider "chunking" a file.</p>
  
  <p>So I am looking for help on steaming the file from disk to the endpoint.  Everything I am running across for .net core API is creating the API to download the file from a POST like a Razor page or Angular page--I already have that. I just need some help on "re-posting" to another API.  </p>
  
  <p>Thanks</p>