Handling Gemini file upload API response with consume_uploaded_entries/3 in LiveView

I’m using the Gemini file upload API to upload files from the client side in a LiveView app. Unlike a typical presigned URL upload flow, Gemini returns a different kind of file URI after a successful upload.

Is it possible to work with this returned file URI in consume_uploaded_entries/3?

export default function (entries, onViewError) {
  entries.forEach(entry => {
    const { file, meta: { presigned_url } } = entry

    const xhr = new XMLHttpRequest()
    xhr.onload = () => {
      if (xhr.status === 200) {
        const { file: { uri } } = JSON.parse(xhr.responseText)
        console.log(uri) // How to treat it in consume_uploaded_entries/3?

        entry.progress(100)
      } else {
        entry.error()
      }
    }
    xhr.onerror = () => entry.error()
    xhr.upload.addEventListener("progress", (event) => {
      if (event.lengthComputable) {
        let percent = Math.round((event.loaded / event.total) * 100)
        if (percent < 100) { entry.progress(percent) }
      }
    })

    onViewError(() => xhr.abort())

    xhr.open("POST", presigned_url, true)

    xhr.setRequestHeader("X-Goog-Upload-Offset", "0")
    xhr.setRequestHeader("X-Goog-Upload-Command", "upload, finalize")

    xhr.send(entry.file)
  })
}

Since pushEvent isn’t available in the uploader, I’m having a hard time working around this issue.

I’ve solve this problem with entry.view.pushHookEvent.