I have to upload an image to the firebase storage. I'm not using the web version of storage (I shouldn't use it). I am using the firebase admin. No problem, I upload the file without difficulty and I get the result in the variable "file".
and if I access the firebase storage console, the image is there. all right.
return admin.storage().bucket().upload(filePath, {destination: 'demo/images/restaurantCover.jpg',
metadata:{contentType: 'image/jpeg'}
public: true
}).then(file =>{
console.log(`file --> ${JSON.stringify(file, null, 2)}`);
let url = file["0"].metadata.mediaLink; // image url
return resolve(res.status(200).send({data:file})); // huge data
}) ;
Now, I have some questions.
Why so much information and so many objects as a response to the
upload ()
method? Reviewing the immense object, I found a property calledmediaLink
inside metadata and it is the download url of the image. but...Why is the url different from the one shown by firebase? Why can not I find the
downloadURL
property?How can get the url of firebase?
- If I use the mediaLink url is there any problem with different urls? (read, update from ios and Web Client)