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

102
Visualizações
GridFS Binary to URL

Is there a way to convert GridFS binary to a URL that can be used on a src?

Let me explain:

When an image is stored on mongoDB by GridFS it creates to files(fs.files & fs.chunks). In fs.chunks the data is stored like so:

_id:ObjectID('')
files_id:ObjectID('')
n:0
data:Binary('/9j/4S...',0)

Exist any way to convert that binary which is an image(a jpg to be precise) into a URL valid for a HTML img tag?

Some kind of URL.createObjectURL()

By the way, I tried to pass the binary file into URL.createObjectURL() and the displayed error is the following:

TypeError: URL.createObjectURL: Argument 1 is not valid for any of the 1-argument overloads.

Thanks in advance.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Ok, I finally find a helpful answer to my question on this other question:

Creating a BLOB from a Base64 string in JavaScript

Here, the GridFS binary which is a base64 binary is converted in to a Blob object. Then the Blob object can be easily passed through the "URL.createObjectURL()"

The function to convert the base64 to blob is provided in the answer.

I hope this is helpfull for someone else.

about 4 years ago · Juan Pablo Isaza 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