C# Upload PDF Files into Firebase Project Storage?

前端 未结 1 1148
一生所求
一生所求 2021-01-13 12:39

Do you guys know how to upload PDF Files directly to a Firebase Project Storage? I searched a lot on the Internet but I found nothing.

Are there some librarys for

相关标签:
1条回答
  • 2021-01-13 13:03

    Try FirebaseStorage.net library.

    Here's a sample 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);
    
    // Construct FirebaseStorage, path to where you want to upload the file and Put it there
    var task = new FirebaseStorage("your-bucket.appspot.com")
        .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;
    

    There is also a related blog post.

    0 讨论(0)
提交回复
热议问题