logo
down
shadow

How to download Firebase results as set?


How to download Firebase results as set?

By : SnowMan1996
Date : November 20 2020, 11:01 PM
With these it helps I have the following wrapped in a completion block: , Try changing to :-
code :
dbRef.child("Employees").queryOrdered(byChild: "deptid").queryEqual(toValue: "100").observeSingleEvent(of : .value, with:{ snapshot in
   if let snapDict = snapshot.value as? [String:AnyObject]{

        for each in snapDict{

              let deptID = each.value["deptid"] as! String

        }
   }
})


Share : facebook icon twitter icon
How to download image file from Firebase Storage based on a reference of Firebase data

How to download image file from Firebase Storage based on a reference of Firebase data


By : Heather Hallet-Schwa
Date : March 29 2020, 07:55 AM
This might help you It seems like you are loosing reference to the $scope which may be due to having your async calls outside of the controller (It's hard to say without looking at your entire code).
First instead of refspaedtServ.on() followed by a setTimeout() you should use refspaedtServ.once() which returns a promise and move the rest of your logic inside the promise. Then you should set the promise inside the $scope directly. Promises can be used in templates as this article shows. For example something like this should work:
code :
myModule.controller('HelloCtrl', function($scope) {
  var refspaedtServ = new Firebase(FBURLSPA + $routeParams.id);
  $scope.spaedServ = $firebaseObject(refspaedtServ);
  $scope.url = refspaedtServ.once("value").then(function(rootSnapshot) {
    var lafoto = rootSnapshot.val().foto;
    console.log("Inside image ", lafoto)
    var starsRef = firebase.storage().ref('fotos' + lafoto);
    return starsRef.getDownloadURL().then(function(url) {
      console.log("la url ", url)  ;
      return url;
    }).catch(function(error) {
      switch (error.code) {
        case 'storage/object_not_found';
      }
    });
  });
})
myModule.controller('HelloCtrl', function($scope) {
  var refspaedtServ = new Firebase(FBURLSPA + $routeParams.id);
  $scope.spaedServ = $firebaseObject(refspaedtServ);
  $scope.url = refspaedtServ.once("value").then(function(snapshot) {
    return snapshot.val().fotoUrl;
  });
})
Firebase Storage - Download URL different from actual Download URL in the console (token differs)

Firebase Storage - Download URL different from actual Download URL in the console (token differs)


By : Shibadatt Mishra
Date : March 29 2020, 07:55 AM
like below fixes the issue Download URLs are invalidated in two ways:
The download URL is deleted in the Firebase Console A new object is uploaded (which effectively deletes the object, and thus the token should expire)
How to download pdf File from Firebase storage using download link in android development

How to download pdf File from Firebase storage using download link in android development


By : Sics
Date : March 29 2020, 07:55 AM
Firebase - getting the download URL (Firebase Storage) and saving it in Firebase realtime database

Firebase - getting the download URL (Firebase Storage) and saving it in Firebase realtime database


By : user3384823
Date : March 29 2020, 07:55 AM
To fix the issue you can do The getDownloadURL() method is asynchronous and returns a Promise which resolves with the downloadURL.
You therefore need to do something along these lines, using the then() method to wait that the Promise resolves:
code :
  uploadTask.snapshot.ref.getDownloadURL().then(function(downloadURL) {
    console.log('File available at', downloadURL);
  });
let downloadURL;
var filename = filenamechosen;
var storageRef = firebase.storage().ref('/dav' + 'projects' + '/' + filename);
var uploadTask = storageRef.put(selectedFile);

uploadTask.on("state_changed",
null,  /// <- See https://firebase.google.com/docs/reference/js/firebase.storage.UploadTask#on
null,
function(){
   // Upload completed successfully, now we can get the download URL
    uploadTask.snapshot.ref.getDownloadURL()
    .then(function(downloadURL) {
        console.log('File available at', downloadURL);
        uploadOne(downloadURL);  // <- We call the uploadOne function passing the downloadURL as parameter
    });
});


function uploadOne(downloadURL){
    let projectinf = document.getElementById("projectinfo").value;
    let name = document.getElementById("studentname").value;
    let cls = document.getElementById("cls").value;
    let email = document.getElementById("email").value;
    let projectlnk = downloadURL;
    let marks = document.getElementById("marks").value;
    let submitfrm = document.getElementById("submitfrm");
    let studentObj = {
        class: cls,
        email: email, 
        projectinfo: projectinf,
        projectlink: projectlnk,
        marks: "lol",
    }
    firebase.database().ref('/schools/dav/').child(`${name}`).set(studentObj)
    .then(function() {
        console.log("done");
      })
      .catch(function(error) {
        console.log(error);
      });
}
Does Firebase Function reading and writing to Firebase Realtime Database contribute to Firebase Realtime Download?

Does Firebase Function reading and writing to Firebase Realtime Database contribute to Firebase Realtime Download?


By : user3656794
Date : March 29 2020, 07:55 AM
wish help you to fix your issue Reading data from the Realtime Database into your Cloud Function is a charged operation.
Note that this only applies to data that you code explicitly read in your Cloud Functions code. The data that is used to trigger your Cloud Function, and is passed into your code in the snapshot, change, and context parameters, is not charged.
shadow
Privacy Policy - Terms - Contact Us © soohba.com