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

196
Visualizações
convert FileContentResult image to object url JS

I'm really stuck at converting a PNG image from unicode (I think) to an object URL. I'm using Vue js to convert it. The data is returned by a .NET application using

return new FileContentResult(ms.ToArray(), "image/png");

In my frontend / client app, I can see that I receive this response enter image description here

But what now? :) I tried a lot of things, without any luck. I'm not too familiar with these types of conversion... I did it once and completely forgot how.
ps: If I use Postman, the image is loaded correctly.
that's what I tried until now:

// for displaying IMGs
      <img :src="files.quickPreview_1" />
      <img :src="files.quickPreview_2" />

// vue data
  data() {
    return {
      files: {
        quickPreview_1: null,
        quickPreview_2: null
      }
    };
  },

// conversions
          var utf8 = unescape(encodeURIComponent(response.data));

          var arr = [];
          for (var i = 0; i < utf8.length; i++) {
            arr.push(utf8.charCodeAt(i));
          }

          // try 1
          const blob1 = new Blob(arr, {
            type: response.headers["content-type"]
          });
          this.files.quickPreview_1 = URL.createObjectURL(blob1);

          // try 2
          const byteArray = new Uint8Array(arr);
          const blob2 = new Blob(byteArray, {
            type: response.headers["content-type"]
          });
          this.files.quickPreview_2 = URL.createObjectURL(blob2);

and the current results if I use console.log: enter image description here

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