Firebase Storage C# library

Tomáš Bezouška
Step Up Labs
Published in
2 min readJan 3, 2017

After FirebaseDatabase.net to access your database and FirebaseAuthentication.net to have your requests authenticated, the time has come for another piece of the Firebase puzzle — Storage.

Firebase Storage

Before we talk about the library I recommend you to get familiar with Firebase Storage. You can read about it in the official docs. In your Firebase Console just click on Storage and you will see all files uploaded to your app. You can also specify your custom rules to allow or deny uploading to specific folders.

FirebaseStorage.net

The library itself mimics the official Javascript SDK. So far it lets you do three things:

  1. Upload any content to Firebase Storage
  2. Get a download link
  3. Delete files

Here is a sample use (.NET Framework 4.5):

As you can see, it is fairly simple. When you call PutAsync to upload the file you get back an instance of FirebaseStorageTask. You can attach an event handler to it to track the upload progress and use await to wait until the upload finishes.

What you may have noticed about the PutAsync method is that it does not actually accept a file reference as its parameter but rather a Stream. This makes it easier to keep this library multi-platform and allows you to upload any content — not just files. For example you can use MemoryStream to construct the content in memory and then just upload it as if it were a file.

In case you are wondering, yes, authentication is also supported. Check out my post about FirebaseAuthentication.net, it works the same way here.

For more samples, check out the Github repository. Other than authentication the sample also shows you how to cancel a running upload.

Where can I get the library?

Install it via Nuget:

Install-Package FirebaseAuthentication.netInstall-Package FirebaseStorage.net -pre

Following frameworks are supported:

  • .NET 4.5+
  • Windows 8.x
  • UWP
  • Windows Phone 8.1
  • CoreCLR

If you have any questions or encounter any errors just raise an issue on GitHub.

--

--