Search

How to Upload File to Firebase Storage using asp.net C#

//Step 1: Create the following function to upload the file

public async void uploadFile()

{

var stream = File.Open(@"d:\sankar.png", FileMode.Open);

var auth = new FirebaseAuthProvider(new Firebase.Auth.FirebaseConfig("Api Key"));

var a = await auth.SignInWithEmailAndPasswordAsync("xxxx@xxxxl.com", "password");

string fn = DateTime.Now.Ticks.ToString()+".jpg";

var task = new FirebaseStorage(

"xxxxxxx-xxxxxx.appspot.com",


new FirebaseStorageOptions

{

AuthTokenAsyncFactory = () => Task.FromResult(a.FirebaseToken),

ThrowOnCancel = true,

})

.Child("Categories")

.Child(fn)

.PutAsync(stream);


task.Progress.ProgressChanged += (s, e) => Console.WriteLine($"Progress: {e.Percentage} %");

var downloadUrl = await task;

}




//Step 2 add the following highlighted one

<%@ Page Title="" Language="C#" MasterPageFile="~/Admin.Master" AutoEventWireup="true" CodeBehind="Category_master.aspx.cs" Inherits="admin.visakhadairy.com.Category_master" Async="true" %>


12 views0 comments

Recent Posts

See All