Egor
Egor

Reputation: 37

Firebase Storage : How to get a download link? C#

I have a code that should return me a download link, but it does not work, the error is that it is incorrectly written. Tell me how to get the download link from Firebase Storage correctly Firebase Storage.

вот мой код:

private void button28_Click(object sender, EventArgs e) {
    var task = new FirebaseStorage("*****-***.appspot.com")
        .Child("data")
        .Child("apps")
        .Child("lols").GetDownloadUrlAsync();
    MessageBox.Show(task.ToString());
}

Upvotes: 2

Views: 1208

Answers (2)

Egor
Egor

Reputation: 37

TUN TUDUN TUN TUN TUN: Here is the answer to the question thank you: https://stackoverflow.com/users/13233657/50-seconds-of-coding

        private void button28_ClickAsync(object sender, EventArgs e)
        {
            // Create a reference to the file we want to download
            _ = getLinkAsync();
            getLinkAsync();

        }
        public async Task getLinkAsync()
        {
            FirebaseStorage storage = new FirebaseStorage("***********.appspot.com");
            var starsRef = storage.Child("test.txt");
            string link = await starsRef.GetDownloadUrlAsync();
            MessageBox.Show(link);
        }

Upvotes: 0

Zuhair Naqi
Zuhair Naqi

Reputation: 1270

To get data, you must use async-await OR apply .then to listen for requests.

Try this approach

// Create a reference to the file we want to download
var starsRef = storageRef.child('images/stars.jpg');

// Get the download URL
starsRef.getDownloadURL()
.then((url) => {
  // Insert url into an <img> tag to "download"
})
.catch((err) => {
  console.log('err', err);
})

Upvotes: 3

Related Questions