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

631
Visualizações
How to resize image from S3 with Sharp?

I am trying to resize the uploaded image from S3 using @aws-sdk/v3 in Node.js API.

First, I get the object (image) from S3 as shown here: https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascriptv3/example_code/s3/src/s3_getobject.ts

...

  const params = { Bucket: AWS_BUCKET_NAME, Key: key }
  const data = await s3.send(new GetObjectCommand(params))
  console.log(` >> Success, bucket returned:`, data) // Log correctly

Then I try to resize the data (image):

  const convert = sharp(data).resize(size, size).webp()

But it throws:

 >> data.type: object
(node:35583) UnhandledPromiseRejectionWarning: Error: Input file is missing
...

And I am not sure how should I upload it back?

What am I doing wrong?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I think the sharp constructor accepts a buffer, but what you're passing it is the entire response from the SDK request. Instead, try passing data.Body to sharp fn like this:

const convert = sharp(data.Body).resize(size, size).webp();

over 4 years ago · Santiago Trujillo 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