Skip to content

FirebaseError: Firebase Storage: An unknown error occurred #8611

Open
@CodingWithTashi

Description

@CodingWithTashi

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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions