Skip to content

step-up-labs/firebase-storage-dotnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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;