Skip to content
Advertisement

How can i upload files on Firebase storage inside folder with key generated names using JavaScript

enter image description here

Here is an image of my Firebase storage which is used by Android and IOS i want save the same from the web also I am trying this it is storing data but not in the folder

var storesRef = rootRef.child('Audio');
storesRef.put(file, metadata);

Advertisement

Answer

You can use Realtime database’s push keys and get random IDs and use them as your file name in Firebase storage:

var filetype = "mp3"

var newPostKey = firebase.database().ref().child('temp').push().key;

var uploadTask = rootRef.child(`Audio/${newPostKey}.${filetype}`).put(file, metadata);
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement