JS, Node.js, Frontend, Backend, Firebase, Express, Patrones, HTML5_APIs, Asincronía, Websockets, Testing
Subir ficheros
// Create a root reference
const storageRef = firebase.storage().ref();
// use the Blob or File API
const file = ...
// Upload the file
storageRef.put(file).then((snapshot) => {
console.log('Uploaded a blob or file!');
});
Descargar ficheros
// Create a root reference
const storageRef = firebase.storage().ref();
storageRef.child('images/stars.jpg').getDownloadURL().then((url) => {
// `url` is the download URL for 'images/stars.jpg'
// This can be downloaded directly:
fetch(url)
.then((response) => response.blob())
.then((file) => {
console.log('Here is the file!', file);
});
// Or inserted into an <img> element:
var img = document.getElementById('myimg');
img.src = url;
}).catch(function(error) {
// Handle any errors
});
Recursos