Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

198
Visualizações
Uncaught (in promise) FirebaseError: Firebase Storage: Object 'images/38564af7conno.PNG' does not exist. (storage/object-not-found) react js

I am using react js to upload images in firebase alongside its post contents so far I have managed to upload an image and its doc but the problem is when I try to put image URL along doc it says the image does not exist and when I check back in my console account I find the uploaded image

down below is my upload codes

const createPost = async () => {
if(image == null){
  const cover = "default";
  await addDoc(postsCollectionRef, {
    title, 
    postContent, 
    created_at,
    cover,
    author: {name: auth.currentUser.displayName, id: auth.currentUser.uid} 
  });
}else{
  const cover = addOn+image.name;
  const storage = getStorage();
  var storageRef = await ref(storage, `images/${cover}`);
  const upload = uploadBytesResumable(storageRef,image,image);
  upload.on("state_changed" , alert("success") , alert);
  await getDownloadURL(storageRef).then(function(url){
    console.log(url);
    
  
  addDoc(postsCollectionRef, {
    title, 
    postContent, 
    created_at,
    cover: {cover, url},
    author: {name: auth.currentUser.displayName, id: auth.currentUser.uid} 
  });
  });
}
navigate("/");};

If I can get relevant examples it will be very helpful some says that the problem is that i am calling url before the image is not upload so i tried to add await but still does not work

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Thanksful to image url that i saw where the problem was it was so simple as I was not considering code flow arrangement

if you come across this problem know that you should take image url inside the then() function as you can see the chane in my codes below

else{
  const cover = addOn+image.name;
  const storage = getStorage();
  var storageRef = await ref(storage, `images/${cover}`);
  const upload = uploadBytesResumable(storageRef,image,image).then(
    () =>{
      getDownloadURL(storageRef).then(function(url){
        console.log(url);
        
      
      addDoc(postsCollectionRef, {
        title, 
        postContent, 
        created_at,
        cover: {cover, url},
        author: {name: auth.currentUser.displayName, id: auth.currentUser.uid} 
      });
    }
  );
  });
}

Thank you very much for the participating

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda