Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

282
Vistas
Downloading file from dataUrl results in `null` text displayed on Chrome, when hovering the file's "download tile"

I'm using the following code to force-download a file (so browser doesn't decide to open it in a new tab):

const fetchFileAndConvertToDataURL = async (mediaUrl: string): Promise<string> => {
  const file = await downloadFileFromMediaGallery(mediaUrl) // API call returning an image stream
  const fileBlob = await file.blob()
    
  return new Promise((resolve, reject) => {
    const reader = new FileReader()
    reader.onloadend = () => resolve(reader.result as string)
    reader.onerror = reject
    reader.readAsDataURL(fileBlob)
  })
}

export const downloadFile = async (botId: BotId, mediaUrl: string, filename?: string) => {
  const dataUrl = await fetchFileAndConvertToDataURL(botId, mediaUrl)

  const a = document.createElement('a')
  a.href = dataUrl
  a.target = '_blank'
  a.download = filename || 'true'
  a.click()
}

And it works well, but when the download finishes in Chrome, and I hover the file's tile in the appearing bottom download dock, word "null" displays:
preview

This is where the source URL ususally gets displayed, so it makes sense "null" is there, since I'm downloading from dataUrl, but I would love to change it - is it possible to influence the content?

Thank you 🙏

about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda