title: How can send file to Firebase using C#
body: <p>I want to send files to Firebase Storage using C#, and I use <a href="https://github.com/step-up-labs/firebase-storage-dotnet" rel="nofollow noreferrer">this package</a> for it.</p>
  
  <p>I wrote the following code to send the file I want to send to Firebase;</p>
  
  <pre><code>public static async Task&lt;bool&gt; SendFile(string path, string name)
  {
      try
      {
          var stream = File.Open(path, FileMode.Open);
  
          var task = new FirebaseStorage(Bucket)
              .Child(name)
              .PutAsync(stream);
  
          var downloadUrl = await task;
      }
      catch (Exception e)
      {
          Console.WriteLine(e);
          return false;
      }
  
      return true;
  }
  </code></pre>
  
  <p>The problem is that the code is not working and following line:</p>
  
  <pre><code>var downloadUrl = await task;
  </code></pre>
  
  <p>Throws an exception:</p>
  
  <blockquote>
    <p>The specified argument was not in the range of valid values. Parameter name: value</p>
  </blockquote>
  
  <p>But I did not do any user verification. I see this package being used actively, but I have not found any explanatory document.</p>
  
  <p>It also gives the following message in detail as an error message</p>
  
  <blockquote>
    <p>Message = "Exception occured while processing the request.\nUrl: <a href="https://firebasestorage.googleapis.com/v0/b/mueasyco-92b3b.appspot.com/o?name=1529582622840.wav" rel="nofollow noreferrer">https://firebasestorage.googleapis.com/v0/b/mueasyco-92b3b.appspot.com/o?name=1529582622840.wav</a>\nResponse: N/A"</p>
  </blockquote>
  
  <p><em>EDIT</em></p>
  
  <p>I uploaded code;</p>
  
  <pre><code>public static async Task SendFile(string path, string name)
          {
              try
              {
                  var auth = new FirebaseAuthProvider(new FirebaseConfig(ApiKey));
                  var a = await auth.SignInWithEmailAndPasswordAsync(email, password);
  
                  var stream = new MemoryStream(File.ReadAllBytes(path));
  
                  var task = new FirebaseStorage("mueasyco-92b3b.appspot.com", new FirebaseStorageOptions
                      {
                          AuthTokenAsyncFactory = () =&gt; Task.FromResult(a.FirebaseToken),
                          ThrowOnCancel = true
                      })
                      .Child(name)
                      .PutAsync(stream);
  
                  var downloadUrl = await task;
              }
              catch (Exception e)
              {
                  Console.WriteLine(e);
              }
          }
  </code></pre>
  
  <p>But now I seem to be having problems with asynchronous programming. The code works until the following line;</p>
  
  <pre><code>var a = await auth.SignInWithEmailAndPasswordAsync(email, password);
  </code></pre>
  
  <p>However, the rest of the code does not work, I think it is waiting for the process to finish. However, I do not want this method to exit without completing its work.</p>
  
  <p><em>EDIT 2</em></p>
  
  <p>I invoked the method with <code>.Wait()</code>, but the authentication section above does not end.</p>