Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

upload image to firebase

const { readFileSync } = require("node:fs");
const firebase = require("../firebase");
const {
  getStorage,
  ref,
  uploadBytes,
  getDownloadURL,
} = require("firebase/storage");
const storage = getStorage();
let image = ""
// Create a reference to 'mountains.jpg'
const storageRef = await ref(storage, "images/" + req.file.filename);

    await uploadBytes(storageRef, readFileSync(req.file.path)).then(
      async (snapshot) => {
        await getDownloadURL(snapshot.ref).then((downloadURL) => {
          console.log(downloadURL.toString());
          image = downloadURL.toString();
        });
      }
    );

    return image;
Comment

PREVIOUS NEXT
Code Example
Javascript :: field array using useFormik 
Javascript :: encrypt decrypt in vanilla javascript 
Javascript :: at in js 
Javascript :: split array into chunks javascript 
Javascript :: how to check if an element exists in an array of objects js 
Javascript :: uncaught (in promise): both the table and dtoptions cannot be empty 
Javascript :: .on click jquery 
Javascript :: this element in javascript 
Javascript :: javascript file on select 
Javascript :: js code sample 
Javascript :: add json object to json array javascript 
Javascript :: mui date picker width 
Javascript :: get specific parent element jquery 
Javascript :: javascript return object property from array 
Javascript :: javascript classes and how to import them 
Javascript :: how to make an array in javascript 
Javascript :: jquery validation with ajax submit 
Javascript :: countdown timer with moment js 
Javascript :: js object clear 
Javascript :: how to change background image dynamically in react 
Javascript :: select element by id 
Javascript :: fetching data with react 
Javascript :: check time javascript 
Javascript :: javascript count character in string 
Javascript :: looping through an array javascript sum 
Javascript :: call json api javascript 
Javascript :: date js add days 
Javascript :: angular loop through key values in map 
Javascript :: install bootstrap in react 
Javascript :: vue js tutorial 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =