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

174
Visualizações
How to download BLOB after compression

i use dropzone.js and image-compressor libraries. But i am struggle to download the blob. Any advices how i can do it . Thats below is my code

// "myDropzone" is the camelized version of the HTML element's ID
Dropzone.options.myDropzone = {
 url:" ",
  transformFile: function(file, done) {
     const imageCompressor = new ImageCompressor();

     imageCompressor.compress(file, {
     // I assume the output image won't have the meta data anymore
     checkOrientation: true,
     // Limit output image width & height
     // For controllable file size & avoid blank output image
     // https://github.com/xkeshi/image-compressor#maxwidth
     maxWidth: 8192,
     maxHeight: 8192,
     // 0.8 is the default and already good enough
     quality: 0.6,
     // Convert ALL PNG images to JPEG
     convertSize: 0,
     })
     .then((result) => {
       // Handle the compressed image file.
       done(result)
console.log(result);

     })
     .catch((err) => {
       // Handle the error
       throw err
     })
  }
};

i try to create a download link and download the "result" , but i get corrupt file

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

0

I found the solution by myself. I made ObjectURL of the blob and after that i create an "a" element

    const url = window.URL.createObjectURL(result);
    const a = document.createElement('a');
    a.style.display = 'none';
    a.href = url;
    // the filename you want
    a.download = result.name;
    document.body.appendChild(a);
    a.click();
   window.URL.revokeObjectURL(url);
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