Why my file isn't uploaded to Firebase's storage (using c# .NET)

Viewed 222

I'm using c# .net and trying to upload a '.png' file to Firebase's storage using the code below. There're no errors, the paths are correct and the program seems to be running well, but the file doesn't exist in Firebase's storage. When I run it, it doesn't stop at my breakpoint located after the "await", but acts like everything is OK and presents the console screen like it finished running... If you have any idea please share it, Thanks!

class Program
{
    static void Main(string[] args)
    {          
        stam();
        Console.ReadLine();
    }

   public async static Task stam()
    {
        var stream = File.Open(@"C:\Users\user\Downloads\qrcode.png", FileMode.Open);

        // Construct FirebaseStorage with path to where you want to upload the file and put it there
        var task = new FirebaseStorage("[mydrive].appspot.com")             
         .Child("qrcode.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 is completed and get the download url
        var downloadUrl = await task;
        Console.WriteLine(downloadUrl);

        showDetails(downloadUrl);       
    }}
2 Answers

You are calling function stam wrong try:

stam().WaitAndUnwrapException();

So, I tried it and finally my file is on Firebase's storage:)

I went to Firebase's console=>storage=>rules, and changed "allow read, write: if request.auth != null;" to just allow read, write; It worked but I guess it's less secure, so if there's a better solution/anything to do with that "request.auth" thing that it's not clear for me what it refers to practically let me know please:)

Related