firebase / firebase-js-sdk

Firebase Javascript SDK
https://firebase.google.com/docs/web/setup
Other
4.86k stars 894 forks source link

FirebaseError: Firebase Storage: An unknown error occurred #8611

Open CodingWithTashi opened 1 month ago

CodingWithTashi commented 1 month ago

Operating System

macOS Sonama 14.6.1 (23G93)

Environment (if applicable)

Chrome Version 130.0.6723.70 (Official Build) (arm64)

Firebase SDK Version

11.0.1

Firebase SDK Product(s)

Storage

Project Tooling

Chrome extension with webpack and tailwind css

Detailed Problem Description

I am trying to upload media file(eg 4mb audio file) to firebase storage with uploadBytesResumable. But I am getting Firebase Storage: An unknown error occurred. When I use uploadBytes it worked fine. Since I need progress to track the upload. This is a showstopper for me.

Error uploading file: FirebaseError: Firebase Storage: An unknown error occurred, please check the error payload for server response. (storage/unknown)

Steps and code to reproduce issue

This code works

function uploadData(
  uint8Array: Uint8Array,
) {
  let app = initializeApp(firebaseConfig)
  const storageRef = ref(getStorage(app), `${"path"}/${"test.mp3"}`)
  let task = uploadBytes(storageRef, uint8Array, {
    contentType: "audio/mpeg",
  })

}

But the below code always fails


function uploadData(
  uint8Array: Uint8Array,
) {
  let app = initializeApp(firebaseConfig)
  const storageRef = ref(getStorage(app), `${"path"}/${"test.mp3"}`)

  const metadata = {
    contentType: "audio/mpeg",
  }
  let uploadTask = uploadBytesResumable(storageRef, uint8Array, metadata)
  uploadTask.on(
    "state_changed",
    (snapshot) => {
      const currentProgress = Math.round(
        (snapshot.bytesTransferred / snapshot.totalBytes) * 100,
      )
      console.log(`Progress: ${currentProgress}%`)
    },
    (error) => {
      console.error("Error uploading file:", error)
    },
    () => {
      console.log("File uploaded successfully")
      getDownloadURL(uploadTask.snapshot.ref)
        .then((url) => console.log("Download URL:", url))
        .catch((err) => console.error(err))
        .finally(() => {
          console.log("File upload completed  ")
        })
    },
  )
}
image

Note: It does work with small mp3(72.24 KB)

google-oss-bot commented 1 month ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.