• Stars
    star
    143
  • Rank 257,007 (Top 6 %)
  • Language
    C#
  • License
    MIT License
  • Created almost 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

C# library for Firebase Storage

FirebaseStorage.net

AppVeyor Build status

Easily upload files and other content to Firebase Storage. More info in a blog post

For Authenticating with Firebase checkout the Firebase Authentication library and related blog post

Installation

// Install release version
Install-Package FirebaseStorage.net -pre

Supported frameworks

.NET Standard 1.1 - see https://github.com/dotnet/standard/blob/master/docs/versions.md for compatibility matrix

Usage

// Get any Stream - it can be FileStream, MemoryStream or any other type of Stream
var stream = File.Open(@"C:\Users\you\file.png", FileMode.Open);

//authentication
var auth = new FirebaseAuthProvider(new FirebaseConfig("api_key"));
var a = await auth.SignInWithEmailAndPasswordAsync("email", "password");

// Constructr FirebaseStorage, path to where you want to upload the file and Put it there
var task = new FirebaseStorage(
    "your-bucket.appspot.com"
     new FirebaseStorageOptions
     {
         AuthTokenAsyncFactory = () => Task.FromResult(a.FirebaseToken),
         ThrowOnCancel = true,
     })
    .Child("data")
    .Child("random")
    .Child("file.png")
    .PutAsync(stream);

// Track progress of the upload
task.Progress.ProgressChanged += (s, e) => Console.WriteLine($"Progress: {e.Percentage} %");

// await the task to wait until upload completes and get the download url
var downloadUrl = await task;