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

142
Visualizações
Is there any way to get base64 encoded string of any remote file in javascript?

I have an image url:

url = "https://wallpaperaccess.com/full/3678503.png";

Is there any way to get base64 encoded string of that remote file in javascript?

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

I found on SO this codesnipet to achieve this. The only problem would be that you will run into CORS Problem. If you are the owner of the page which hosted the image you can configure up to avoid CORS.

const toDataURL = url => fetch(url)
  .then(response => response.blob())
  .then(blob => new Promise((resolve, reject) => {
    const reader = new FileReader()
    reader.onloadend = () => resolve(reader.result)
    reader.onerror = reject
    reader.readAsDataURL(blob)
  }))


toDataURL('https://wallpaperaccess.com/full/3678503.png')
  .then(dataUrl => {
    console.log('RESULT:', dataUrl)
  })

And here the Link where i found the source: https://stackoverflow.com/a/20285053/14807111

about 4 years ago · Santiago Gelvez 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