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

107
Visualizações
First arg must be a Blob object or a File object. Image compressor

I am making an image compressor. In the image you see a simple design with a dragon drop to fill in ur files. But i want to download the image i keep getting one error (displayed below).

[This is what i got so far.][1] [1]: https://i.stack.imgur.com/2RJ3v.png

This is my download funtion but when i press the button to download i keep getting 1 error

  function download(file, res) {
    console.log(file);
    var fdata = new FormData()
    fdata.append('upload_preset', 'image_name')
    fdata.append('file', file)
    // converts the picture and instant download the new image.
    imageConversion.compressAccurately(file, 50).then(res=>{
      console.log(res)
      imageConversion.downloadFile(res)
    })
  }

Error:

conversion.js:1 Uncaught (in promise) Error: compressAccurately(): First arg must be a Blob object or a File object.

I tried a lot of things but i can't really figure it out. Someone got any idea how to solve this?

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

0

I figured it out. I had to add an Array and make the file excisable for all functions.

function handleFiles(files) {
  window.files = files;
  files = [...files];
  files.forEach(previewFile);
}

function download() {
  Array.from(files).forEach((element) => {
    // converts the picture and instant download the new image.
    imageConversion.compressAccurately(element, 50).then((res) => {
      console.log(res);
      imageConversion.downloadFile(res, 'test');
    });
  });
}
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