0

I created an app and when I upload an Image I'm storing in a database the "Storage Location" of the file

Storage location gs://******/carriersPictures/calinonaca1@gmail.com-profilePicture-1570123057815.jpg

for example, I store this because I didn't find a function to store the download URI only the Storage Location of file using this

 picturesUrls.add(taskSnapshot.getUploadSessionUri().toString());

But, I want to display those images in a web page. I'm using NodeJs as backend with template view EJS. But how can I convert in the NodeJs app the Storage Location URI to download URI.

exports.getApprove = (req,res,next) => {
const email = req.params.email;
const ref = firebase.database().ref("User");
ref.orderByChild("email").equalTo(email).on("child_added", function(snapshot) {
    let pictureUrls = [];


    for(let i = 0 ;i < snapshot.val().picturesUrls.length ;i++) {


        pictureUrls.push(snapshot.val().picturesUrls[i]);
    }


const user = {
    CVC: snapshot.val().CVC,
    activated: snapshot.val().activated,
    address: snapshot.val().address,
    cardnumber: snapshot.val().cardnumber,
    city: snapshot.val().city,
    cnp:snapshot.val().cnp,
    country:snapshot.val().country,
    email:snapshot.val().email,
    expiredate:snapshot.val().expiredate,
    fullname:snapshot.val().fullname,
    password:snapshot.val().password,
    phone:snapshot.val().phone,
    pictureUrls: pictureUrls,
    rate: snapshot.val().rate,
    state: snapshot.val().state,
    type: snapshot.val().type,
    zipcode :snapshot.val().zipcode

}

res.render('main/approve', {
    pageTitle:'Drivie | APPROVE',
    path:'/aprove',
    user:user

  });


});
}

I want picturesUrls array to get the Download URLs not the Storage Location. I mean, I know in my database I store the Storage Locations of the images, but how can I query the storage for every Storage Location URL to get the Download URL. Didn't find too much in the official docs.

Thank you very much!

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Calin Onaca
  • 175
  • 3
  • 14
  • The download URL can only be retrieve from the client-side Firebase SDKs for Cloud Storage. The closest equivalent in the server-side SDKs is a signed URL, which is shown here: https://stackoverflow.com/questions/42956250/get-download-url-from-file-uploaded-with-cloud-functions-for-firebase – Frank van Puffelen Oct 03 '19 at 18:33
  • ok, thank you very much – Calin Onaca Oct 03 '19 at 20:22

0 Answers0